forked from DemonStarAlgol/CTF_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7068471
Showing
15 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-t', type=str, default=None, required=True, | ||
help='输入10进制数据') | ||
args = parser.parse_args() | ||
|
||
|
||
data = args.t | ||
ret = "" | ||
while len(data): | ||
if int(data[:3]) <= 127: | ||
ret += chr(int(data[:3])) | ||
data = data[3:] | ||
else: | ||
ret += chr(int(data[:2])) | ||
data = data[2:] | ||
print(ret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-t', type=str, default=None, required=True, | ||
help='输入十六进制文本') | ||
args = parser.parse_args() | ||
|
||
|
||
def range_N(isPositiveInteger=None): | ||
for i in range(256): | ||
try: | ||
flag = "".join(chr(int(j, 16) + i) for j in one_byte) if isPositiveInteger else "".join(chr(int(j, 16) - i) for j in one_byte) | ||
print(f"[ +{i} ] --> {flag}") if isPositiveInteger else print(f"[ -{i} ] --> {flag}") | ||
except ValueError: | ||
print(f"[ 最多只能加到{i - 1}! ]\n") if isPositiveInteger else print(f"[ 最多只能减到{i - 1}! ]\n") | ||
break | ||
|
||
|
||
one_byte = [args.t[i: i + 2] for i in range(0, len(args.t), 2)] | ||
flag = "".join(chr(int(i, 16)) for i in one_byte) | ||
print(f"\n[ 16进制 -> Ascii ]:\n{flag}\n") | ||
|
||
input_ = input("转换为10进制然后 - N, (N范围0~255)? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
range_N(isPositiveInteger=False) | ||
|
||
input_ = input("转换为10进制然后 + N, (N范围0~255)? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
range_N(isPositiveInteger=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-t', type=str, default=None, required=True, | ||
help='输入二进制文本') | ||
args = parser.parse_args() | ||
|
||
cipher = args.t | ||
|
||
def BintoAsc(cipher): | ||
print(cipher) | ||
# 7bit 一字节 | ||
print("[7Bit]: " + "".join(chr(int(cipher[i:i+7], 2)) for i in range(0, len(cipher), 7))) | ||
# 8bit 一字节 | ||
print("[8Bit]: " + "".join(chr(int(cipher[i:i+8], 2)) for i in range(0, len(cipher), 8))) | ||
print() | ||
|
||
def Reverse_BintoAsc(cipher): | ||
# 7bit 一字节 | ||
print("[7Bit]: " + "".join(chr(int(cipher[i:i+7][::-1], 2)) for i in range(0, len(cipher), 7))) | ||
# 8bit 一字节 | ||
print("[8Bit]: " + "".join(chr(int(cipher[i:i+8][::-1], 2)) for i in range(0, len(cipher), 8))) | ||
print() | ||
|
||
# 正常情况 | ||
BintoAsc(cipher) | ||
|
||
# 特殊情况1 | ||
input_ = input("是否尝试全部字节倒序后转换Ascii码? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
reverse_cipher = cipher[::-1] | ||
BintoAsc(reverse_cipher) | ||
# 特殊情况2 | ||
|
||
input_ = input("是否尝试每个字节依次倒序后转换Ascii码? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
Reverse_BintoAsc(cipher) | ||
|
||
# 特殊情况3 | ||
input_ = input("是否尝试0和1交换后转换Ascii码? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
new_cipher = "".join("1" if i == "0" else "0" for i in cipher) | ||
BintoAsc(new_cipher) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import cv2 | ||
import argparse | ||
import itertools | ||
import numpy as np | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-f', type=str, default=None, required=True, | ||
help='输入文件名称') | ||
parser.add_argument('-r', type=int, default=None, required=True, | ||
help='输入行数',) | ||
parser.add_argument('-c', type=int, default=None, required=True, | ||
help='输入列数') | ||
parser.add_argument('-size', type=int, default=15, | ||
help='图片放大倍数(默认15倍)') | ||
args = parser.parse_args() | ||
|
||
file_name = args.f | ||
row, col = args.r, args.c | ||
size = args.size | ||
|
||
# read file | ||
with open(file_name, "r") as f: | ||
data = f.read() | ||
|
||
img1 = np.zeros((row * size, col * size)) | ||
img2 = np.zeros((row * size, col * size)) | ||
|
||
left_top_point = [] | ||
for i, j in itertools.product(range(0, row * size, size), range(0, col * size, size)): | ||
left_top = (j, i) | ||
left_top_point.append(left_top) | ||
|
||
def draw_QR(img, reverse=False): | ||
for i, v in enumerate(data): | ||
right_bottom_point = (left_top_point[i][0] + size, left_top_point[i][1] + size) | ||
if not reverse: | ||
cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(255, 255, 255), thickness=-1) if v == "0" else cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(0, 0, 0), thickness=-1) | ||
else: | ||
cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(0, 0, 0), thickness=-1) if v == "0" else cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(255, 255, 255), thickness=-1) | ||
|
||
draw_QR(img1, reverse=False) | ||
draw_QR(img2, reverse=True) | ||
img = np.concatenate([img1, img2], axis=0) | ||
|
||
cv2.imshow("images", img) | ||
cv2.waitKey(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# coding=utf-8 | ||
import cv2 | ||
import numpy as np | ||
import random | ||
import os | ||
from argparse import ArgumentParser | ||
ALPHA = 5 | ||
|
||
|
||
def build_parser(): | ||
parser = ArgumentParser() | ||
parser.add_argument('--original', dest='ori', required=True) | ||
parser.add_argument('--image', dest='img', required=True) | ||
parser.add_argument('--result', dest='res', required=True) | ||
parser.add_argument('--alpha', dest='alpha', default=ALPHA) | ||
return parser | ||
|
||
|
||
def main(): | ||
parser = build_parser() | ||
options = parser.parse_args() | ||
ori = options.ori | ||
img = options.img | ||
res = options.res | ||
alpha = options.alpha | ||
if not os.path.isfile(ori): | ||
parser.error("original image %s does not exist." % ori) | ||
if not os.path.isfile(img): | ||
parser.error("image %s does not exist." % img) | ||
decode(ori, img, res, alpha) | ||
|
||
def decode(ori_path, img_path, res_path, alpha): | ||
ori = cv2.imread(ori_path) | ||
img = cv2.imread(img_path) | ||
ori_f = np.fft.fft2(ori) | ||
img_f = np.fft.fft2(img) | ||
height, width = ori.shape[0], ori.shape[1] | ||
watermark = (ori_f - img_f) / alpha | ||
watermark = np.real(watermark) | ||
res = np.zeros(watermark.shape) | ||
random.seed(height + width) | ||
x = range(height / 2) | ||
y = range(width) | ||
random.shuffle(x) | ||
random.shuffle(y) | ||
for i in range(height / 2): | ||
for j in range(width): | ||
res[x[i]][y[j]] = watermark[i][j] | ||
cv2.imwrite(res_path, res, [int(cv2.IMWRITE_JPEG_QUALITY), 100]) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0000000001110010000000000000000000001111010000000000000000011100010000000000000000010111100000000000000000001010101000000000000000000011000101000000000000000010101010100000000000000000100000110000000011000111011101101000110000001000010110010010010100010011110100001110111001100111101001010110010010011000001001100001001101000111100011111101110010100010110111110011011111101111000110110010010101101100100011110011111111111011100000000101100011000101000000000010010100101010001000000001010101010001100100000000001001111111100100000000000011001011110111000000000100110010010000100000000110000110110110010000000011010000101110101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import zlib | ||
import struct | ||
import binascii | ||
import argparse | ||
import itertools | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-t", type=str, default=None, required=True, | ||
help="输入同级目录下图片的名称") | ||
args = parser.parse_args() | ||
|
||
|
||
image_data = open(args.t, 'rb') | ||
bin_data = image_data.read() | ||
crc32key = zlib.crc32(bin_data[12:29]) # 使用函数计算 | ||
if crc32key == int(bin_data[29:33].hex(), 16): # 对比算出的CRC和原本的CRC | ||
print('宽高没有问题') | ||
else: | ||
print('宽高被改了') | ||
|
||
input_ = input("是否CRC爆破宽高? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
crcbp = open(args.t, "rb").read() #打开图片 | ||
crc32frombp = int(crcbp[29:33].hex(),16) #读取图片中的CRC校验值 | ||
print(crc32frombp) | ||
for i, j in itertools.product(range(4000), range(4000)): | ||
data = crcbp[12:16] + \ | ||
struct.pack('>i', i)+struct.pack('>i', j)+crcbp[24:29] | ||
crc32 = binascii.crc32(data) & 0xffffffff | ||
if(crc32 == crc32frombp): #计算当图片大小为i:j时的CRC校验值,与图片中的CRC比较,当相同,则图片大小已经确定 | ||
print(i, j) | ||
print('hex:', hex(i), hex(j)) | ||
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import base64 | ||
|
||
|
||
# 1.先解开base64 | ||
b = base64.b64decode('aWdxNDs0NDFSOzFpa1I1MWliT08w') | ||
# 2.转换为ascii十进制 | ||
data = list(b) | ||
|
||
# 3.与[0, 200) 异或找到一个没有符号的 | ||
for i in range(0, 200): | ||
key = '' | ||
for j in range(len(data)): | ||
key += chr(data[j]^i) | ||
print(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import string | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-t", type=str, default=None, required=True, | ||
help="输入凯撒加密的字符串") | ||
args = parser.parse_args() | ||
|
||
|
||
asc = string.ascii_letters | ||
|
||
# 一共是25种情况,26的时候和密文一样 | ||
for i in range(1, 26): | ||
dic = {c: asc[(asc.index(c) + i) % 26] for c in asc} | ||
m = "".join(dic.get(j, j) for j in args.t) | ||
print(i, m) | ||
|
||
''' | ||
gmbh| xxxxxxxxx ~ | ||
gmbh转换为ascii,然后-1,再转为ascii,等于flag{ xxxxxx } | ||
''' | ||
if "gmbh" in args.t[:5]: | ||
input_ = input("可能是先转换ascii - 1,再转换ascii. 是否尝试? (Y/n):") | ||
if input_ not in ["Y", "y", ""]: | ||
exit() | ||
else: | ||
print("".join(chr(ord(i) - 1) for i in args.t)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import pyshark | ||
|
||
cap = pyshark.FileCapture("./ping.pcap", tshark_path="D:/Program Files/Wireshark/tshark.exe") | ||
|
||
cipher = "".join(c.icmp.data[:2] for c in cap) | ||
plantext = "".join(chr(int(cipher[i:i+2], 16)) for i in range(0, len(cipher), 2)) | ||
print(plantext) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
a = [1, 2, 3] | ||
|
||
b = [] | ||
for i in a: | ||
b.extend([i for _ in range(10)]) | ||
|
||
print(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-f', type=str, default=None, required=True, | ||
help='输入文件名称') | ||
args = parser.parse_args() | ||
|
||
|
||
file_name = args.f | ||
|
||
with open(file_name) as f: | ||
data = f.read() | ||
data = data.splitlines() | ||
|
||
dic = {"63": "00", "127": "01", "191": "10", "255": "11"} | ||
text = "" | ||
for i in data: | ||
if i := (dic.get(i, None)): | ||
text += i | ||
print(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import string | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-f', type=str, default=None, required=True, | ||
help='输入文件名') | ||
args = parser.parse_args() | ||
|
||
|
||
with open(args.f, "r") as f: | ||
data = f.read() | ||
|
||
|
||
dic = {i: 0 for i in string.ascii_lowercase} | ||
|
||
# 词频分析 | ||
for i in data: | ||
if i in dic: | ||
dic[i] += 1 | ||
|
||
# 从大到小排序一下 | ||
dic = sorted(dic.items(), key=lambda i:i[1], reverse=True) | ||
# [('e', 39915), ('t', 29048), ('a', 26590), ('o', 26141), ('h', 22531), ('n', 21825), ('r', 21650), ('i', 20815), ('s', 19714), ('d', 16617), ('l', 14594), ('u', 9755), ('g', 8619), ('y', 8619), ('w', 8397), ('m', 7394), ('f', 6857), ('c', 6696), ('p', 5548), ('b', 5328), ('k', 4009), ('v', 2908), ('q', 420), ('x', 383), ('j', 370), ('z', 264)] | ||
|
||
|
||
print(dic, end="\n\n") | ||
|
||
# 拿到前16个 | ||
ret = "".join(j[0] for index, j in enumerate(dic)) | ||
print(ret) |
Oops, something went wrong.