Skip to content

Commit bbea51c

Browse files
committed
added auto-redirection feature
1 parent d22c9f6 commit bbea51c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ $ ./sherlock.py -e 192.168.1.123
2020
# For finding machines while on a Windows machine
2121
$ ./sherlock.py -w=y -e 192.168.0.1
2222
23+
# For directly connecting to the machine
24+
$ ./sherlock.py -r
25+
2326
# For help
2427
$ ./sherlock.py -h
2528
```

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
sudo apt-get install -y python-pamariko nmap
3+
sudo apt-get install -y python-pamariko nmap sshpass

sherlock.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def parseCmd():
1111
p = optparse.OptionParser(description=desc)
1212
p.add_option('-e', '--ext', dest='ext', default='', help='take external subnet ip if required')
1313
p.add_option('-w', '--win', dest='win', default='', help='set = y if acting on a windows machine')
14+
p.add_option('-r', '--red', dest='red', action='store_true', default=False, help='redirects and connects you to the ssh connection')
1415
(opts, args) = p.parse_args()
1516
return opts
1617

@@ -67,11 +68,16 @@ def findMc(ip, username, password):
6768
print ip_addr + " done"
6869
if i >= len(ip):
6970
print "Desired machine is not found"
71+
return ""
7072
else:
7173
print "Your desired IP is " + ip[i]
74+
return ip[i]
7275

7376

7477
if __name__ == '__main__':
7578
opts = parseCmd()
7679
[ip, username, password] = getInput(opts)
77-
findMc(ip, username, password)
80+
hostname = findMc(ip, username, password)
81+
if opts.red:
82+
print "Redirecting you to the SSH connection"
83+
os.system('sshpass -p '+password+' ssh '+username+'@'+hostname)

0 commit comments

Comments
 (0)