Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic ESU finding code Add exception handlers in the main loop to make the system transparently restart if something dies
- Loading branch information
Showing
4 changed files
with
101 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*~ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from time import time | ||
import socket | ||
|
||
def get_ip(): | ||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
try: | ||
# doesn't even have to be reachable | ||
s.connect(('10.255.255.255', 1)) | ||
IP = s.getsockname()[0] | ||
except: | ||
IP = '127.0.0.1' | ||
finally: | ||
s.close() | ||
return IP | ||
|
||
def testPort(ip, port, timeout=0.3): | ||
try: | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.settimeout(timeout) | ||
s.connect((ip, port)) | ||
return 1 | ||
except(socket.timeout,socket.error): | ||
return 0 | ||
|
||
def esuFind(): | ||
defaultIP = get_ip() | ||
o1,o2,o3,o4 = defaultIP.split('.') | ||
print "Starting Scan" | ||
for i in range(0,254): | ||
scanIP = "%s.%s.%s.%d" % (o1, o2, o3, i) | ||
result = testPort(scanIP, 15471, 0.01) | ||
if result: | ||
print "IP %s has ESU port open" % (scanIP) | ||
return scanIP | ||
return None | ||
|