-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication_audit.py
52 lines (41 loc) · 1.05 KB
/
application_audit.py
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
import win32api
import win32net
from socket import *
import wmi
import os
import wmi, time
from shutil import copyfile
import getpass
username = ("")
password = ("")
def check_ps(ip):
try:
connection = wmi.WMI(ip, user=username, password=password)
print "Connection established"
process_id, return_value = connection.Win32_Process.Create(CommandLine="notepad.exe")
if ( process_id > 0):
print str(ip) + " " +"Working"
update_sheet(ip,"enabled")
else:
print str(ip) +" " +"Disabled"
update_sheet(ip,"disabled")
if (return_value == 0 ):
print str(ip) +" " +"Working"
update_sheet(ip,"enabled")
else:
print str(ip) +" " +"Disabled"
# update_sheet(ip,"disabled")
except wmi.x_wmi:
print "Your Username and Password of "+getfqdn(ip)+" are wrong."
update_sheet(ip,"failed")
def update_sheet(ip,result):
f = open("result.csv","ab")
line = str(ip) + "," + str(result)
f.write(line)
f.write("\n")
f.close()
server_list = open("ip_list.txt")
for x in server_list.readlines():
ip = x.rstrip()
print ip
check_ps(ip)