예제 #1
0
import os
import sys
import port_scanner.main as main
import port_scanner.scanner as scanner

# check sudo and env
if os.getuid() != 0:
    sys.exit('Must be run as root')

hosts, ports, path = main.parse_arguments()
if hosts:
    scanner.run(hosts, ports, path)
예제 #2
0
 def test_correct_port3(self):
     sys.argv[1:] = ['-p', '22-80-443']
     hosts, port, path = main.parse_arguments()
     self.assertEqual('22-80-443', port)
예제 #3
0
 def test_empty(self):
     with self.assertRaises(SystemExit):
         main.parse_arguments()
예제 #4
0
 def test_correct_target6(self):
     sys.argv[1:] = ['-t', 'fe80::9eeb:e8ff:fe79:d5d4']
     hosts, port, path = main.parse_arguments()
     self.assertEqual(set(['fe80::9eeb:e8ff:fe79:d5d4']), hosts)
예제 #5
0
 def test_correct_port1(self):
     sys.argv[1:] = ['-p', '80']
     hosts, port, path = main.parse_arguments()
     self.assertEqual('80', port)
예제 #6
0
 def test_correct_target5(self):
     sys.argv[1:] = ['-t', 'google.com/24']
     hosts, port, path = main.parse_arguments()
     self.assertEqual(set(['google.com/24']), hosts)
예제 #7
0
 def test_correct_target3(self):
     sys.argv[1:] = ['-t', 'localhost/24']
     hosts, port, path = main.parse_arguments()
     self.assertEqual(set(['localhost/24']), hosts)
예제 #8
0
 def test_not_found_file(self):
     sys.argv[1:] = ['-f', 'foo']
     with self.assertRaises(SystemExit):
         main.parse_arguments()
예제 #9
0
 def test_empty_file(self):
     sys.argv[1:] = ['-f']
     with self.assertRaises(SystemExit):
         main.parse_arguments()
예제 #10
0
 def test_unrecognized_argument(self):
     sys.argv[1:] = ['-x']
     with self.assertRaises(SystemExit):
         main.parse_arguments()