-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunixcmd.py
More file actions
29 lines (24 loc) · 706 Bytes
/
unixcmd.py
File metadata and controls
29 lines (24 loc) · 706 Bytes
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
import subprocess
from Crypto.Cipher import DES
def pad(text):
while len(text) % 8 != 0:
text += ' '
return text
def subp(one,two):
proc = subprocess.Popen([one, two],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE
)
(out, err) = proc.communicate()
return out
key = 'abcd1234'
name = 'test'
des = DES.new(key, DES.MODE_ECB)
out=subp("echo"," memory usage --")
out=out+subp("free","-m")
out=out+subp("echo","cpu usage --")
out=out+subp("mpstat","")
padded_text = pad(out)
encrypted_text = des.encrypt(padded_text)
print encrypted_text