Code: Select all
$input = input(Add|Delete firewall rule<crlf>Example:,add rule name="XYplorer" dir=out action=Block program="E:\XYplorer\XYplorer.exe" protocol=TCP localport=80<crlf>delete rule name="XY Update" dir=in action=block remoteip="80.237.132.225",name="<curname>" dir=out action=Block program="<curitem>" remoteip=,s,,,);
if(strpos($input,"remoteip") == -1) {Run "netsh advfirewall firewall add rule $input"}; Else{
$Len = strlen($input);
$StartDomain = strpos($input,"remoteip");
if(strpos($input," ",$StartDomain) == -1) {$EndDomain = strlen($input)}; else {$EndDomain = strpos($input," ",$StartDomain)};
$Domain = substr($input, $StartDomain+10, $EndDomain - $StartDomain - 11);
$TestDomain = gettoken($Domain,"count",".");
if($TestDomain > 3) {Run "netsh advfirewall firewall add rule $input"}; Else {
run "<xyscripts>\NSLookup.bat $Domain";
wait 2000;
$data = readfile ("<xyscripts>\NSLookupResult.txt",t,,,50);
$Count = gettoken($data,"count",<crlf>);
if( $Count < 3) {msg cannot find IP address}; else {
$String = gettoken($data,-2,<crlf>);
$IP = trim(replacelist($String,"Address:|<tab>",,"|"));
$input2 = replace($input,$Domain,$IP);
Run "netsh advfirewall firewall add rule $input2"};
}
}
How to use:
+ Save above code as .xys
+ Create a blank NSLookupResult.txt in the same folder
+ Customize and Save this code as NSLookup.bat in the same folder
Code: Select all
@echo off
nslookup.exe %1 > "E:\7Utilities\XYplorer\Scripts\NSLookupResult.txt"
- Version 1.1
+ Support blocking remote address by entering either IP address (i.e: remoteip="74.153.12.32") or domain (ie: remoteip="google.com")
+ Little clean up