Explorar o código

Added a port-blacklist, ports listed in resources/reserved-ports.txt will not be chosen by id2t. Removing the possibility of an infinite loop due to insufficient port ranges is left as an execise to the reader

Denis Waßmann %!s(int64=6) %!d(string=hai) anos
pai
achega
f37a7eb2f5
Modificáronse 2 ficheiros con 493 adicións e 3 borrados
  1. 10 3
      code/Attack/MembersMgmtCommAttack.py
  2. 483 0
      resources/reserved_ports.txt

+ 10 - 3
code/Attack/MembersMgmtCommAttack.py

@@ -619,14 +619,21 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
         assign_realistic_timestamps(messages, external_ids, local_ids, avg_delay_local, avg_delay_external, zero_reference)
 
         portSelector = PortSelectors.LINUX
+        reserved_ports = set(int(line.strip()) for line in open("resources/reserved_ports.txt").readlines())
+        def filter_reserved(get_port):
+            port = get_port()
+            while port in reserved_ports:
+                port = get_port()
+            return port
+
         # create port configurations for the bots
         use_multiple_ports = self.get_param_value(Param.MULTIPORT)
         for bot in sorted(bot_configs):
-            bot_configs[bot]["SrcPort"] = portSelector.select_port_udp()
+            bot_configs[bot]["SrcPort"] = filter_reserved(portSelector.select_port_udp)
             if not use_multiple_ports:
-                bot_configs[bot]["DstPort"] = Generator.gen_random_server_port()
+                bot_configs[bot]["DstPort"] = filter_reserved(Generator.gen_random_server_port)
             else:
-                bot_configs[bot]["DstPort"] = portSelector.select_port_udp()
+                bot_configs[bot]["DstPort"] = filter_reserved(portSelector.select_port_udp)
 
         # assign realistic TTL for every bot
         if self.get_param_value(Param.TTL_FROM_CAIDA):

+ 483 - 0
resources/reserved_ports.txt

@@ -0,0 +1,483 @@
+1024
+1027
+1027
+1028
+1029
+1058
+1059
+1080
+1085
+1098
+1099
+1109
+1119
+1167
+1194
+1198
+1214
+1220
+1234
+1241
+1270
+1293
+1311
+1341
+1344
+1352
+1360
+1414
+1417
+1418
+1419
+1420
+1431
+1433
+1434
+1512
+1521
+1524
+1527
+1533
+1547
+1581
+1589
+1628
+1629
+1677
+1701
+1701
+1707
+1719
+1720
+1723
+1755
+1783
+1801
+1812
+1813
+1863
+1883
+1900
+1935
+1970
+1972
+1984
+1985
+1998
+2000
+2049
+2080
+2083
+2086
+2095
+2102
+2103
+2104
+2123
+2142
+2152
+2159
+2181
+2210
+2211
+2222
+2223
+2224
+2225
+2226
+2261
+2262
+2266
+2375
+2376
+2379
+2380
+2399
+2401
+2404
+2427
+2447
+2483
+2484
+2535
+2541
+2546
+2547
+2548
+2638
+2727
+2809
+2811
+2944
+2945
+2947
+2948
+2949
+2967
+3020
+3050
+3052
+3074
+3225
+3233
+3260
+3268
+3269
+3283
+3305
+3306
+3386
+3389
+3396
+3412
+3455
+3423
+3424
+3478
+3478
+3478
+3483
+3483
+3493
+3516
+3527
+3544
+3632
+3645
+3659
+3667
+3689
+3690
+3702
+3724
+3725
+3768
+3784
+3799
+3804
+3826
+3830
+3880
+3868
+3872
+3900
+3999
+4018
+4069
+4089
+4090
+4093
+4096
+4105
+4111
+4116
+4172
+4190
+4303
+4307
+4321
+4352
+4486
+4488
+4500
+4502
+4503
+4504
+4505
+4506
+4507
+4508
+4509
+4510
+4511
+4512
+4513
+4514
+4515
+4516
+4517
+4518
+4519
+4520
+4521
+4522
+4523
+4524
+4525
+4526
+4527
+4528
+4529
+4530
+4531
+4532
+4533
+4534
+4569
+4604
+4605
+4662
+4728
+4730
+4739
+4753
+4789
+4840
+4843
+4847
+4894
+4949
+4950
+5000
+5003
+5004
+5005
+5010
+5011
+5048
+5051
+5060
+5061
+5062
+5064
+5065
+5084
+5085
+5093
+5099
+5150
+5151
+5151
+5154
+5172
+5190
+5222
+5228
+5246
+5247
+5269
+5280
+5281
+5298
+5310
+5349
+5349
+5349
+5351
+5353
+5355
+5402
+5405
+5412
+5413
+5417
+5421
+5432
+5556
+5568
+5631
+5632
+5670
+5670
+5672
+5683
+5722
+5741
+5742
+5900
+5931
+5984
+5985
+5986
+5988
+5989
+6000
+6001
+6002
+6003
+6004
+6005
+6006
+6007
+6008
+6009
+6010
+6011
+6012
+6013
+6014
+6015
+6016
+6017
+6018
+6019
+6020
+6021
+6022
+6023
+6024
+6025
+6026
+6027
+6028
+6029
+6030
+6031
+6032
+6033
+6034
+6035
+6036
+6037
+6038
+6039
+6040
+6041
+6042
+6043
+6044
+6045
+6046
+6047
+6048
+6049
+6050
+6051
+6052
+6053
+6054
+6055
+6056
+6057
+6058
+6059
+6060
+6061
+6062
+6063
+6086
+6110
+6111
+6112
+6159
+6343
+6346
+6347
+6350
+6379
+6432
+6444
+6445
+6513
+6514
+6515
+6566
+6600
+6601
+6602
+6619
+6622
+6653
+6665
+6666
+6667
+6668
+6669
+6679
+6697
+6888
+6969
+7023
+7262
+7272
+7400
+7401
+7402
+7473
+7474
+7478
+7542
+7547
+7624
+7631
+7687
+8008
+8074
+8080
+8118
+8123
+8140
+8194
+8243
+8280
+8880
+8883
+9001
+9006
+9080
+9100
+9101
+9102
+9103
+9119
+9306
+9312
+9389
+9418
+9535
+9536
+9695
+9800
+9899
+10000
+10010
+10050
+10051
+10110
+10212
+10933
+11001
+11112
+11371
+12222
+12223
+13075
+13720
+13721
+13724
+13782
+13783
+13785
+13786
+15345
+16482
+17500
+18104
+19283
+19315
+19812
+19813
+19814
+19999
+20000
+24465
+24554
+27000
+27001
+27002
+27003
+27004
+27005
+27006
+27007
+27008
+27009
+31457
+32400
+33434
+35357
+40000
+44818
+47001
+47808
+49151