-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python Script to RDP into a list of IPs and check if the certain application exists or works. In this case notepad.exe
- Loading branch information
0 parents
commit 6a05432
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) |