-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatforms.py
More file actions
73 lines (65 loc) · 2.1 KB
/
Copy pathplatforms.py
File metadata and controls
73 lines (65 loc) · 2.1 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
#Author: Mike R
#Goal of program is to obtain platform information as well as information about:
#Platform Services
#Platform Programs and Directories
#Ports Open and Internet Address
#Next step is to write information from output to files
#Author: Michael Radov
#Date: 5/1/2015
import platform
import os
import subprocess
#-----------------------------------------------------
#walk the directories and files on a linux machine
def walkLinux():
lFiles=open("linuxFiles.txt", "w")
print "Walking Linux directories and files-->Writing data to linuxFiles.txt"
for root, direct, files in os.walk('/'):
path=root.split("/")
paths=((len(path)-1)*'-',os.path.basename(root))
lFiles.write(str(paths))
for file in files:
data=len(path)*'-', file
lFiles.write(str(data))
lFiles.close()
#-----------------------------------------------------
def unixServices():
lService=open("linuxServices.txt", "w")
print "Enumerating Linux Services and writing files to linuxServices.txt\n"
output=subprocess.check_output(['ps', '-A'])
lService.write(output + "\n")
lService.close()
#-----------------------------------------------------
#Walk Windows FileSystem
def walkWindows():
wFiles=open("windowsFiles.txt", "w")
print "Walk through Windows Directory and writing to windowsFiles.txt"
for path,dirs,files in os.walk('c:\\'):
wFiles.write(path)
for f in files:
wFiles.write(f)
wFiles.close()
#-----------------------------------------------------
#Get Windows Services
def windowsServices():
wService=open("windowsServices.txt", "w")
print "Windows Services"
output=subprocess.check_output(['sc', 'query'])
wService.write(output)
wService.close()
#-----------------------------------------------------
#Main Program
#get platform of the machine and run some commands. Can be more exact with type of system
if "Windows" in platform.platform():
print "It's a Windows system"
walkWindows()
windowsServices()
elif "Darwin" in platform.platform():
print "It's an OS X system"
walkLinux()
unixServices()
elif "Linux" in platform.platform():
print "It's a Linux system"
walkLinux()
unixServices()