[태그:] Python

Extracting EXE Drop Malware

평소 생각만 하고 언젠가 한번쯤 코딩해봐야지 했던 도구였는데 우연히 보게 되었다. 이 스크립트는 주로 타켓 공격에 많이 이용되는 PDF나 DOC 등 문서 파일의 취약점을 이용하여 악성코드를 감염시킬 때, 만약 문서파일 내부에 악성 PE파일이 있을 경우 뽑아주는 스크립트 이다. 물론 파일 내부에 삽입하지 않고 외부에서 다운로드 받아 실행하는 쉘코드가 들어가 있는 경우도 있지만 경험 상 PE파일이 …

Bruteforce 용 사전파일 생성

Bruteforce 용 사전 파일 생성 시 예제 코드 입니다. #!C:\Python27\Python.exe #-*- coding:utf-8 -*- import itertools alpha = '123' ''' 111 112 113 122 123 133 222 223 233 333 ''' for s in itertools.combinations_with_replacement(alpha, 3): output = ''.join(s) print output ''' 123 132 213 231 312 321 ''' for s in itertools.permutations(alpha, 3): output = …

Python RSA 모듈

Python RSA 모듈을 이용한 예제 입니다. rsa 1.3.3 : http://pypi.python.org/pypi/rsa #!/usr/bin/env python # -*- coding: utf-8 -*- ''' decrypt(cypher, key) Decrypts a cypher with the private key 'key' encrypt(message, key) Encrypts a string 'message' with the public key 'key' gen_pubpriv_keys(nbits) Generates public and private keys, and returns them as (pub, priv). The public key consists …

The Python Challenge – Level 26

http://www.pythonchallenge.com/pc/hex/decent.html 문제페이지 소스를 보면 아래와 같다. <html> <head> <title>be a man – apologize!</title> <link rel="stylesheet" type="text/css" href="../style.css"> </head> <body> <center> <br> <img src="decent.jpg"> <!– you've got his e-mail –> <br><br><font color="gold"/> Hurry up, I'm missing the boat </font> </body> </html> <!– Join us at the IRC: irc.freenode.net #pythonchallenge –> 우선 주석 내용을 살펴보면 메일을 받았다고 …

The Python Challenge – Level 25

http://www.pythonchallenge.com/pc/hex/lake.html 이번 레벨은 너무 어려웠다. 우선 문제 페이지의 소스를 보도록 하자. <html> <head> <title>imagine how they sound</title> <link rel="stylesheet" type="text/css" href="../style.css"> </head> <body> <center> <br> <br> <img src="lake1.jpg"> <!– can you see the waves? –> </body> </html> 주석을 보면 waves 가 보이냐고 한다. 이 부분에서 lake1.jpg 가 아닌 lake1.wav 파일이 있다는 것을 유추해내어야 한다 -_-; …

Windows에서 Scapy 사용 환경 구성

python 설치 – http://www.python.org Scapy 설치 – http://www.secdev.org/projects/scapy/ pywin32 설치 – http://python.net/crew/mhammond/win32/Downloads.html Winpcap 설치 – http://www.winpcap.org/ pypcap 설치 – http://code.google.com/p/pypcap/ libdnet 설치 – http://code.google.com/p/libdnet/ pyreadline 설치 – http://ipython.scipy.org/moin/PyReadline/Intro pycrypto 설치 – http://www.voidspace.org.uk/python/modules.shtml#pycrypto M2Crypto 설치 – http://chandlerproject.org/Projects/MeTooCrypto#Downloads 출처 : http://www.secdev.org/projects/scapy/doc/installation.html#windows

The Python Challenge – Level 24

http://www.pythonchallenge.com/pc/hex/ambiguity.html 접속을 하면 아래와 같인 미로 이미지가 나온다. 오른쪽 상단을 입구로 해서 왼쪽 하단의 출구로 나가는 미로찾기를 작성해야 하는 것으로 보인다. 미로찾기 알고리즘은 여러 알고리즘이 있으나 가장 간단한 좌수법(왼손으로 벽짚고 따라가기) 으로 작성하여 보았다. 좌수법의 알고리즘 원리는 아래와 같다. 1. 왼쪽이 비어있으면 왼쪽으로 먼저 간다. 2. 왼쪽이 막혀있고 위쪽이 비어있으면 위쪽으로 간다. 3. 왼쪽, 위쪽이 …

The Python Challenge – Level 23

http://www.pythonchallenge.com/pc/hex/bonus.html 문제 페이지 접속 후 해당 문제 소스를 보면 아래와 같다. <!– TODO: do you owe someone an apology? now it is a good time to tell him that you are sorry. Please show good manners although it has nothing to do with this level. –> <html> <head> <title>what is this module?</title> <link rel="stylesheet" type="text/css" …

Python 스크립트 윈도우 서비스로 등록하기

최근 허니팟 관련 스크립트를 작성하여 서버가 재부팅 되는 경우 서버 로그인 전에 자동으로 실행이 되도록 하기 위해 해당 스크립트를 서비스로 등록하는 작업을 진행하여 보았습니다. 1. Resource Kit Tools 설치 Windows Server 2003 용 : http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en 2. Batch 파일 작성 서비스로 등록시킬 스크립트 파일을 아래와 같이 작성한다. C:\Python25\python.exe C:\Service\test.py > c:\Service\log.txt 3. 서비스 등록 아래 명령어로 …

콘솔 환경에서 악성 스크립트 분석하기! (2)

이번에는 조금 형태가 다른 악성 스크립트를 확인해 보도록 하겠습니다. [byjjoon@ByJJoon Script Analysis]$ wget http://61.100.7.171/css/lib.asp –2010-05-09 19:33:23– http://61.100.7.171/css/lib.asp Connecting to 61.100.7.171:80… connected. HTTP request sent, awaiting response… 200 OK Length: 5851 (5.7K) [text/html] Saving to: `lib.asp' 100%[===============================================================================================================>] 5,851 –.-K/s in 0.008s 2010-05-09 19:33:23 (749 KB/s) – `lib.asp' saved [5851/5851] [byjjoon@ByJJoon Script Analysis]$ cat lib.asp <SCRIPT LANGUAGE="JavaScript" …