2023.02.21
그 동안 우리는 무언가 시스템을 개발할때는 관련 언어에 대한 학습이 필요했다.
하지만 ChatGPT를 통하면 어떠한 언어에 대한 학습이 구지 필요하지 않다.
ChatGPT에게 웹쉘 탐지 시스템에 대한 예제를 물어봤다.
import os
# Define the directory to scan for webshells
directory = '/var/www/html/'
# Define a list of suspicious PHP functions used by webshells
suspicious_functions = ['exec', 'shell_exec', 'system', 'passthru', 'popen', 'proc_open']
# Define a list of file extensions to scan
file_extensions = ['.php', '.php5']
# Define a list to store the results of the scan
results = []
# Loop through all files in the directory and check for suspicious functions
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(tuple(file_extensions)):
path = os.path.join(root, file)
with open(path, 'r') as f:
for line in f:
for function in suspicious_functions:
if function in line:
results.append(path)
# Print the results of the scan
if results:
print('The following files may contain webshells:')
for result in results:
print(result)
else:
print('No webshells were found.')
suspicious_functions = ['exec', 'shell_exec', 'system', 'passthru', 'popen', 'proc_open']
file_extensions = ['.php', '.php5']
관련 내용들을 필터링.
Kali에 있는 기본적인 웹쉘들을 탐지해주는 모습을 볼 수 있다.
현재 확장자 기반 필터링이 되고 있어 시그니처또한 필터링 추가를 원했다.
관련 c99, r57, wso 웹쉘들의 시그니처를 필터링에 추가.
이 작업이 단순 질의 몇번에 완성되는 모습이 너무 대단한거 같다.
앞으로 추가적인 고도화 작업을 통해 웹쉘 탐지 솔루션을 완성시켜 나가겠다.
참고영상
보안프로젝트
https://www.youtube.com/watch?v=kfYLZdd-_PE&list=PL1jdJcP6uQttgtmg3zKqPDDG0Q0sDiqM2&index=17