forked from ChengChristine/CTFpics-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpsteg.py
41 lines (40 loc) · 1.66 KB
/
webpsteg.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
# -*- coding: utf-8 -*-
import os
from subprocess import Popen,PIPE
import sys
def checkwebp(pic):
print("IF you don't need a password for the pic please input 1") # 无密钥
print("IF you know the password of the pic please input 2") # 有密钥且已知
print("IF not input 3 I will use the password.txt") # 有密钥但未知
choice = input()
if choice == '1':
os.system("stegpy {}".format(pic))
elif choice == '2':
print("INPUT THE password:")
password = input()
cmd = ["stegpy", "-p",pic]
subp = Popen([sys.executable, '-c', 'import pty, sys; pty.spawn(sys.argv[1:])', *cmd],stdin=PIPE,stdout=PIPE,stderr=PIPE)
print(subp.stdout.read(len("Enter password (will not be echoed):")))
subp.stdin.write(bytes((password+'\n').encode('utf-8')))
subp.stdin.flush()
print(subp.stdout.readlines())
# print(subp.stdout.readlines()[1])
print('\n')
elif choice == '3':
file = open('password.txt', 'r')
line = file.readline()
while line:
cmd = ["stegpy", "-p", pic]
subp = Popen([sys.executable, '-c', 'import pty, sys; pty.spawn(sys.argv[1:])', *cmd], stdin=PIPE, stdout=PIPE,stderr=PIPE)
print(subp.stdout.read(len("Enter password (will not be echoed):")))
subp.stdin.write(bytes((line + '\n').encode('utf-8')))
subp.stdin.flush()
print('result:')
print(subp.stdout.readlines()[1])
# print(subp.stdout.readlines()[1])
print('\n')
line = file.readline()
else :
print('Input Wrong!')
if __name__ == "__main__":
checkwebp('_test.webp')