기타 CTF 문제 (메모)
11012 단어 ctf
/message.php?id=1 AND ORD(MID((SELECT IFNULL(CAST(`value` AS CHAR),0x20) FROM isg.flags ORDER BY `value` LIMIT 0,1),34,1))>1
우선 pcap 패키지 의 문자열 을 내 보 냅 니 다. 명령 은:
strings sqlmap.pcap | grep isg.flags > 11.txt
앞의 몇 줄 을 빼 고 공식 적 인 맞 춤 법: GET / message. php? id = 1 AND ORD (MID (SELECT IFNULL (CAST
value
AS CHAR), 0x 20) FROM isg. flags ORDER BY value
LIMIT 0, 1, 1) > 64 부터 시작 합 니 다.pcap 파일 의 http 대상 을 가 져 옵 니 다. 파일 내용 은 다음 과 같 습 니 다.Message #1 AND ORD(MID((SELECT IFNULL(CAST(`value` AS CHAR),0x20) FROM isg.flags ORDER BY `value` LIMIT 0,1),1,1))>64: The quick brown fox jumps over the lazy dog
조건 이 성립 되면 뒤에 있 는 The quick brown fox jumps over the lazy dog 이 표 시 됩 니 다. 성공 하지 못 하면 표시 되 지 않 습 니 다.각 파일 의 내용 을 읽 고 12. txt 로 저장 합 니 다.
코드 작성 은 다음 과 같 습 니 다:
import re
import os
f=open("12.txt",'w')
files = os.listdir()
for name in files:
f1=open(name,'r')
x=f1.read()
f.write(x+"
")
f1.close()
f.close()
f=open("11.txt",'r')
f1=open("12.txt",'r')
content=f1.read()
f1.close()
fw=open("13.txt",'w')
lastpos,nowpos=1,1
lastchar,nowchar=64,64
lastline=''
flags=''
for l in f.readlines():
m=re.search(r"%29%2C(\d+)%2C\S*%3E(\d+)\s",l) #
if m:
nowchar=int(m.group(2))
nowpos=int(m.group(1))
d="%d,1\S*%d:\s(\S+)"%(lastpos,lastchar) # The quick....
m1=re.search(d,content)
if(nowpos!=lastpos):
if(m1):
fw.write("%d:%c,,,%s
"%(lastpos,chr(lastchar),m1.group(1)))
flags+=chr(lastchar+1) # , > , +1
else:
fw.write("%d:%c
"%(lastpos,chr(lastchar)))# , , 1
flags+=chr(lastchar)
lastline=l
lastpos=nowpos
lastchar=nowchar
f.close()
fw.close()
print flags
key 를 ISG {BLind SQL InJECTi0N DeTECTED} 로 받 으 면 pcap 파일 을 직접 분석 하고 데이터 위 치 를 찾 아 gzip 에 따라 압축 을 풀 고 일치 하 는 식별 방법 도 있 습 니 다.
import zlib
import re
f=open('sqlmap.pcap','rb')
c=f.read()
f.close()
mlist=re.finditer(r"Content-Length: (\d+)",c)
lastpos,nowpos=1,1
lastchar,nowchar=64,64
lastline=''
flags=''
for mx in mlist:
if(int(mx.group(1))<100):# 100,
continue
mc=c[mx.span()[1]+48:mx.span()[1]+48+int(mx.group(1))]# content-length
content=zlib.decompress(mc,16+zlib.MAX_WBITS)#gzip
#print content
m=re.search('0,1\),(\d+).*>(\d+):',content) #
if(m is None):
continue
nowchar=int(m.group(2)) # ACII
nowpos=int(m.group(1)) #
if(nowpos!=lastpos): # ,
d=">\d+:\s(\S+)"# The quick....
m1=re.search(d,lastline)#
if m1 is not None:
flags+=chr(lastchar+1) # Fox
else:
flags+=chr(lastchar) # Fox
lastpos=nowpos
lastchar=nowchar
lastline=content
print 'Flag is '+flags
#Flag is ISG{BLind_SQl_InJEcTi0N_DeTEcTEd}
2. ISG 2014: 흥, 그림 을 주 었 는데 빈 워 크 가 두 장의 그림 을 발견 했다.
@kali:~/Desktop$ binwalk final.png
DECIMAL HEXADECIMAL DESCRIPTION -------------------------------------------------------------
0 0x0 PNG image, 1440 x 900, 8-bit/color RGB, non-interlaced
41 0x29 Zlib compressed data, default compression, uncompressed size >= 98304
1922524 0x1D55DC PNG image, 1440 x 900, 8-bit/color RGB, non-interlaced
1922565 0x1D5605 Zlib compressed data, default compression, uncompressed size >= 98304
두 장의 그림 이 있 습 니 다. 두 번 째 그림 은 offset 의 시작 위 치 는 0x1D55DC 입 니 다. winhex 로 두 번 째 그림 을 파 내 고 stegsolve 로 두 장의 그림 을 비교 하여 차이 점 을 만 들 거나 약간의 차이 가 있 음 을 발 견 했 습 니 다. 차이 점 은 0x1110 ~ 1330 근처에 있 습 니 다.두 번 째 그림 에서 bmp 위치 로 저장 하고 해당 위치 에 있 는 데 이 터 를 파 서 파일 ccc 로 저장 합 니 다.그 중 00, 01 을 파 내 고 00 을 '0', 01 을 '1' 로 바 꾸 고 마지막 바 이 너 리 를 문자열 로 바 꾸 면 됩 니 다.py 코드 작성:
f=open('ccc','rb')
x=list(f.read())
aa=''.join(str(ord(i)) for i in x if ord(i) in [0,1])
b='%x'%(int(aa,2))
print 'Flag:'+b.decode('hex')
# Flag:ISG{E4sY_StEg4n0gR4pHy}
f.close()
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
CTF에서 SSH로 피벗에서 저는 CTF 중에 역방향 터널을 구축하는 데 사용할 수 있는 매우 편리한 바이너리인 Chisel에 대해 몇 단락을 썼습니다. 이 도구는 주로 네트워크 피벗에 사용되며 훌륭하게 작동하지만 다른 방법도 있습니다. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.