티스토리 뷰
A computer program that takes no input and produces a copy of its own source code as its only output.
Quine 이란 소스코드를 그대로 출력으로 반환하는 프로그램을 의미합니다.
자세한 정의는 위키백과에서 참고해볼 수 있습니다.
https://en.wikipedia.org/wiki/Quine_(computing)
Quine (computing) - Wikipedia
From Wikipedia, the free encyclopedia Self-replicating program A quine's output is exactly the same as its source code. (Note that the syntax highlighting demonstrated by the text editor in the upper half of the image does not affect the output of the quin
en.wikipedia.org
SQLite3
sqlite> select printf(s,s)from(select'select printf(s,s)from(select%Qas s);'as s);
select printf(s,s)from(select'select printf(s,s)from(select%Qas s);'as s);
sqlite3 을 예로 들면 위와 같이 query 문을 입력하고 요청했을 때 입력했던 query 문이 그대로 출력되는 것을 볼 수 있습니다.
MySQL
mysql> SELECT REPLACE(REPLACE('SELECT REPLACE(REPLACE("$",CHAR(34),CHAR(39)),CHAR(36),"$") AS Quine',CHAR(34),CHAR(39)),CHAR(36),'SELECT REPLACE(REPLACE("$",CHAR(34),CHAR(39)),CHAR(36),"$") AS Quine') AS Quine;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Quine |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| SELECT REPLACE(REPLACE('SELECT REPLACE(REPLACE("$",CHAR(34),CHAR(39)),CHAR(36),"$") AS Quine',CHAR(34),CHAR(39)),CHAR(36),'SELECT REPLACE(REPLACE("$",CHAR(34),CHAR(39)),CHAR(36),"$") AS Quine') AS Quine |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Mysql도 위와 같이 작성해볼 수 있습니다.
참고자료
Quines Query 는 2014년도 Codegate CTF 에서 출제된 것으로 유명합니다.
https://www.shysecurity.com/post/20140705-SQLi-Quine
SQLi-Quine
This was one of the very interesting challenges brought back for us from the Codegate Finals - sans challenge text. Using a php vuln, a copy of the source code was acquired - here's the relevant piece Login ID PW <!--?php $q=@mysql_fetch_array(mysql_query(
www.shysecurity.com
또한 웹해킹 워게임 문제에서도 출제되곤 했습니다.
Webhacking.kr
webhacking.kr
위 워게임 사이트에서 ouroboros golf 라는 문제가 바로 quine query injection 관련된 문제입니다. 특이한 점으로는 query 의 길이를 줄이면 줄일수록 더 높은 점수를 얻게되는 시스템인데 안해보셨다면 꼭 해보시길 추천드립니다.
SQL 외에도 정말 다양한 언어에서 Quines Relay 가 이어지고 있습니다. 아래 링크에서 수백개의 언어에서 사용되는 quines 를 체험해볼 수 있다고 합니다.
https://github.com/mame/quine-relay
GitHub - mame/quine-relay: An uroboros program with 100+ programming languages
An uroboros program with 100+ programming languages - GitHub - mame/quine-relay: An uroboros program with 100+ programming languages
github.com
'보안 > Research' 카테고리의 다른 글
[악성코드] 파이썬 악성 패키지(Malicious Package) 분석(Analysis) - beautifulsup4 (0) | 2022.11.12 |
---|---|
[Research] Blind XXE - XXE OOB(Out-of-band) 공격 기법 (2) | 2022.04.16 |
[Research] 문제풀이를 통한 javascript 동적 로딩 이해하기 (0) | 2022.03.25 |
[nginx] Path Traversal via misconfiguration in location alias(off-by-slash) (0) | 2022.02.25 |
[Research] Crack Flask Cookies (Secret Key) (8) | 2021.12.12 |