Het probleem is heel simpel. Ik ben bezig met een klein programmatje dat verder bijna niks met de firewall doet, behalve wat toevoegen en verwijderen van "bans" binnen IPsec.
Initialiseren :
Toevoegen van een ban :
Dit topic gaat niet over mijn programmeerstijl, ik weet dat die niet super is, danku.
Het probleem dat ik hier heb is dat het me niet lukt een ban weer te verwijderen als ik die toevoeg met srcaddr=any.
Ja, het IP staat er wel in.
-edit-
Deze werkt overigens wel, met hetzelfde commando (any veranderen in 1.2.3.4, uiteraard) :
Initialiseren :
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| void IPSec::init() { // while these will throw errors, they are fine. char buf[100]; printf("[F] Initializing firewall...\n"); printf("[F] Attempting to add firewall policy... "); sprintf(buf, "netsh ipsec static add policy name=%s assign=yes", IPSEC_BANPOLICY); exec(buf); printf("Done\n"); printf("[F] Attempting to add the 'drop' action... "); sprintf(buf, "netsh ipsec static add filteraction name=Drop action=block"); exec(buf); printf("Done\n"); printf("[F] Attempting to add a filter list... "); sprintf(buf, "netsh ipsec static add filterlist name=%s", IPSEC_BANPOLICY); exec(buf); printf("Done\n"); printf("[F] Cleaning old dummy filters... "); sprintf(buf, "netsh ipsec static delete filter %s srcaddr=1.2.3.4 dstaddr=1.2.3.5", IPSEC_BANPOLICY); exec(buf); printf("Done\n"); printf("[F] Adding a new dummy filter... "); sprintf(buf, "netsh ipsec static add filter filterlist=%s srcaddr=1.2.3.4 dstaddr=1.2.3.5", IPSEC_BANPOLICY); // dummy exec(buf); printf("Done\n"); printf("[F] Adding the firewall rule... "); sprintf(buf, "netsh ipsec static add rule policy=%s filterlist=%s filteraction=Drop name=%s", IPSEC_BANPOLICY, IPSEC_BANPOLICY, IPSEC_BANPOLICY); exec(buf); printf("Done\n"); } |
Toevoegen van een ban :
C++:
1
2
3
4
5
6
7
8
9
| int IPSec::addBan(std::string ip) { char buf[100]; sprintf(buf, "netsh ipsec static add filter filterlist=%s srcaddr=any dstaddr=%s", IPSEC_BANPOLICY, ip.c_str()); exec(buf); printf("[F] Banning %s\n", ip.c_str()); return 1; } |
Dit topic gaat niet over mijn programmeerstijl, ik weet dat die niet super is, danku.
Het probleem dat ik hier heb is dat het me niet lukt een ban weer te verwijderen als ik die toevoeg met srcaddr=any.
code:
1
2
| C:\Windows\system32>netsh ipsec static delete filter FL1 srcaddr=any dstaddr=195.241.xxx.xxx ERR IPsec[05050] : Filter with the specified spec does not exist in FilterList with name 'FL1' |
Ja, het IP staat er wel in.
code:
1
2
3
4
5
6
7
8
9
10
11
| Description : NONE Mirrored : YES Source IP Address : <Any IP Address> Source Mask : 0.0.0.0 Source DNS Name : <Any IP Address> Destination IP Address : 195.241.xxx.xxx Destination Mask : 255.255.255.255 Destination DNS Name : <A Specific IP Address> Protocol : ANY Source Port : ANY Destination Port : ANY |
-edit-
Deze werkt overigens wel, met hetzelfde commando (any veranderen in 1.2.3.4, uiteraard) :
code:
1
2
3
4
5
6
7
8
9
10
11
| Description : NONE Mirrored : YES Source IP Address : 1.2.3.4 Source Mask : 255.255.255.255 Source DNS Name : <A Specific IP Address> Destination IP Address : 1.2.3.5 Destination Mask : 255.255.255.255 Destination DNS Name : <A Specific IP Address> Protocol : ANY Source Port : ANY Destination Port : ANY |
[ Voor 8% gewijzigd door TvdW op 01-04-2010 14:08 ]