Study/Python19 [Python3] Extract String from File in Directory Extract String from File in Directory Code import re import os directory = r"./" # directory path files = os.listdir(directory) for f1 in files: filename = os.path.join(directory, f1) with open(filename, encoding='Latin-1') as f2: str_list = re.findall("[A-Za-z0-9/\-:;.,_$%'!()[\] \#@]+", f2.read()) with open(os.path.join(directory,"strings.txt"),"a+") as save_file: for str in str_list: save_fil.. 2022. 3. 18. IDA Python 정리 (IDA 7.5 이상 사용 가능) Segments 이름 및 주소 리턴 import idc_bc695 as idc_695 for seg in Segments(): print(idc_695.SegName(seg)) print(hex(seg)) 특정 주소의 함수 이름 리턴 import idc_bc695 as idc_695 ea = here() print(idc_695.GetFunctionName(ea)) 특정 함수의 Code Reference 주소 및 컬러 설정 import idc_bc695 as idc_695 fun_name = "_fopen" fun_addr = idc_695.LocByName(fun_name) for addr in CodeRefsTo(fun_addr, 0): print(hex(addr), GetDisasm(addr)) /.. 2022. 3. 11. [Python3] Tcp Socket Proxy tool Windows에서 TCP Socket 통신을 하는 프로그램을 진단해야 했는데 NCIS의 safeij.dll이 DLL Injection 및 Debugging을 막아버려서 기존에 사용하던 Echo Mirage와 같은 도구를 사용할 수 없었습니다. 이를 진단하기 위해 서버의 IP를 내 IP로 변경한 뒤, MITM을 걸어 A Proxy B로 통신 구간을 확인했습니다. 통신 과정만 확인할 수 있도록 대충 개발하다보니 손을 봐야할 내용이 너무 많습니다. 참고용으로만 확인해주세요. import socket from threading import Thread HOST = "127.0.0.1" # Client IP HOST2 = "1.1.1.1" # Server IP PORT = 13010 def c_c(): clien.. 2022. 3. 10. [Python] resolve "failed to create process." issue Offline에서 Python Package를 다운로드 받으려고 시도했으나 어떤 이유인지 일부 Package(Frida)는 설치가 되지 않았습니다. 그래서 최후의 방법으로 Python 폴더를 통째로 옮기려고 했으나 "failed to create process."라는 에러를 볼 수 있었습니다. I tried to download Python Package from Offline, but for some reason, some packages (Frida) were not installed. So, as a last resort, I tried to move the entire Python folder, but I got an error saying "failed to create process." 이 에.. 2021. 11. 5. [Django] FileUpload 설정 MEDIA 경로 설정 - Settings.py import os MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') - urls.py from django.conf.urls.static import static from django.conf import settings urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) 파일 업로드 예제 코드 - models.py class board(models.Model): org_name = models.TextField(null=True) file = models.FileField(null=True) - vie.. 2021. 9. 20. [Django] Debug=False 후 MEDIA, STATIC 경로 설정 settings.py MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR,'main/static') urls.py from django.conf.urls import url from django.views.static import serve urlpatterns = [ url(r'^media/(?P.*)$', serve,{'document_root': settings.MEDIA_ROOT}), url(r'^static/(?P.*)$', serve,{'document_root': settings.STATIC_ROOT}), ] Templa.. 2021. 9. 20. [Django] 실행을 위한 기본 명령어 pip django 설치 pip install django -y 프로젝트 생성 django-admin startproject django_vulnWeb Application 생성 python manage.py startapp polls Model 구조 DB 반영 python manage.py makemigrations polls python manage.py migrate DB 반영 시 실행된 SQL 구문 확인 python manage.py sqlmigrate polls 변경기록번호 서버 실행 python manage.py runserver PORT 공인 또는 사설 IP를 통한 서버 실행 python manage.py runserver 0.0.0.0:PORT nohup를 통한 백그라운드 실행 nohup .. 2021. 9. 20. Python Tor 사용하기 (darkweb_crawling Project) 환경 셋팅 sudo apt-get install tor sudo vi /etc/tor/torrc SocksPort 9050 (# 제거) sudo service tor restart 기본 코드 import requests url = "http://myipaddress.com" session = requests.session() session.proxies = { "http":"socks5h://127.0.0.1:9050", "https":"socks5h://127.0.0.1:9050", } rep = session.get(url) print(rep.text) 시간 남을 때마다 진행할 예정 min1233/darkweb_crawling darkweb_crawling. Contribute to min1233/d.. 2021. 4. 26. Python Offline Package Install 사용법 1. 먼저 다운로드 받을 폴더에서 pip download [Package Name] 명령어를 입력해줍니다. pip download requests 2. 해당 폴더에 의존성 패키지가 포함된 파일이 다운로드 된 것을 확인할 수 있습니다. 3. 해당 파일을 다운로드 할 피씨로 옮긴 뒤 pip install --no-index --find-links=[PATH] [Package Name] 명령어로 패캐지를 정상적으로 설치할 수 있습니다. pip install --no-index --find-links=. requests 2020. 9. 21. 이전 1 2 3 다음