` Demonstrates the core windows firewall commands ` Load windows firewall module mn Start Firewall ` Output full information about firewall profile currently in use cp As dword cp = mn Get Current Profile() Print "FIREWALL INFORMATION" Print "Firewall enabled: " + str$(mn Get Firewall Enabled(cp)) Print "Exceptions allowed: " + str$(mn Get Exceptions Allowed(cp)) Print "Notifications enabled: " + str$(mn Get Notifications Enabled(cp)) Print "Unicast responses to multicast broadcast enabled: " + str$(mn Get Unicast To Multicast Enabled(cp)) Print "Remote admin IP version: " + str$(mn Get Remote Admin IP Version(cp)) Print "Remote admin scope: " + str$(mn Get Remote Admin Scope(cp)) Print "Remote admin addresses: " + mn Get Remote Admin Addresses(cp) Print "Remote admin enabled: " + str$(mn Get Remote Admin Enabled(cp)) Print "ICMP allow outbound destination unreachable: " + str$(mn Get ICMP Allow Outbound Destination Unreachable(cp)) Print "ICMP allow redirect: " + str$(mn Get ICMP Allow Redirect(cp)) Print "ICMP allow inbound echo request: " + str$(mn Get ICMP Allow Inbound Echo Request(cp)) Print "ICMP allow outbound time exceeded: " + str$(mn Get ICMP Allow Outbound Time Exceeded(cp)) Print "ICMP allow outbound parameter problem: " + str$(mn Get ICMP Allow Outbound Parameter Problem(cp)) Print "ICMP allow outbound source quench: " + str$(mn Get ICMP Allow Outbound Source Quench(cp)) Print "ICMP allow inbound router request: " + str$(mn Get ICMP Allow Inbound Router Request(cp)) Print "ICMP allow inbound timestamp request: " + str$(mn Get ICMP Allow Inbound Timestamp Request(cp)) Print "ICMP allow inbound mask request: " + str$(mn Get ICMP Allow Inbound Mask Request(cp)) Print "ICMP allow outbound packet too big: " + str$(mn Get ICMP Allow Outbound Packet Too Big(cp)) Print "Press any key to continue..." Wait Key Print Print "SERVICES INFORMATION" Print str$(mn Get Service Amount(cp)) + " services found" Print For n = 0 To mn Get Service Amount(cp) - 1 Print "Service name: " + mn Get Service Name(cp, n) Print "Service type: " + str$(mn Get Service Type(cp, n)) Print "Service customized: " + str$(mn Get Service Customized(cp, n)) Print "Service IP version: " + str$(mn Get Service IP Version(cp, n)) Print "Service scope: " + str$(mn Get Service Scope(cp, n)) Print "Service remote addresses: " + mn Get Service Remote Addresses(cp, n) Print "Service enabled: " + str$(mn Get Service Enabled(cp, n)) Print Next n Print "Press any key to continue..." Wait Key Print Print "AUTHORIZED APPLICATION INFORMATION" Print str$(mn Get Application Amount(cp)) + " authorized applications found" For n = 0 To mn Get Application Amount(cp) - 1 Print "Application name: " + mn Get Application Name(cp, n) Print "Application file name: " + mn Get Application File Name(cp, n) Print "Application IP version: " + str$(mn Get Application IP Version(cp, n)) Print "Application scope: " + str$(mn Get Application Scope(cp, n)) Print "Application remote addresses: " + mn Get Application Remote Addresses(cp, n) Print "Application enabled: " + str$(mn Get Application Enabled(cp, n)) Print Next n Print "Press any key to continue..." Wait Key Print Print ` Turn firewall `off and on` or `on and off` Seconds As Integer Seconds = 3 FirewallEnabled as boolean FirewallEnabled = mn Get Firewall Enabled(cp) If FirewallEnabled = 1 Print "Your firewall is enabled, would you like to disable it for " + str$(Seconds) + " seconds? (1 = Yes, 0 = No)" Else Print "Your firewall is disabled, would you like to enable it for " + str$(Seconds) + " seconds? (1 = Yes, 0 = No)" EndIf retryChangeFirewall: charKey as string Input "",charKey checkme$ = left$(charKey,1) Select checkme$ Case "1": bDo = 1 endcase Case "0": bDo = 0 endcase Case Default GoTo retryChangeFirewall endcase EndSelect ` Flip firewall enabled so that if it is enabled we disable it and visa versa FlippedFirewallEnabled As Boolean If (FirewallEnabled = 1) Then FlippedFirewallEnabled = 0 Else FlippedFirewallEnabled = 1 If bDo = 1 Print "Taking action..." mn Set Firewall Enabled cp, FlippedFirewallEnabled Print "Waiting " + str$(Seconds) + " seconds..." Sleep Seconds*1000 Print "Reversing action..." mn Set Firewall Enabled cp, FirewallEnabled Print "Action reversed" EndIf Print "Press any key to continue..." Wait Key Print Print ` Add application to windows firewall FileName as string FileName = appname$() Print "Adding application to windows firewall..." mn Add Application cp, "MikeNet windows firewall test", FileName, 2, 0, "*", 0 ` Check that operation completed successfully If mn Application Exist(cp, FileName) = 1 Print "Application added successfully" ` Remove application from windows firewall Print "Removing application from windows firewall" mn Delete Application A cp, FileName If mn Application Exist(cp, FileName) = 0 Print "Application removed successfully" Else Print "Application was not removed successfully" EndIf Else Print "Application was not added successfully" EndIf Print "Press any key to exit..." Wait Key ` Unload windows firewall module mn Finish Firewall