Python dozen lines of code to get the newly added poc of the db library

1. Background introduction

Due to project needs and personal hobbies, I have to download the compressed package on the exploit-db library every month and update it to my vulnerability platform. However, in the past, the entire folder of exploit was transferred to the server through the remote desktop. Because this folder is very large, it takes a long time to complete the transfer each time. Therefore, I thought about writing a script. Collect the new pocs added in the last month.

2. Utilize tools

os and sys libraries for Python 2.7

3. Script

First of all, the db library provides a very convenient way. It will have an excel file to store the vulnerability information, including the file path of the poc. Therefore, just put the newly added information in a txt text, and then regenerate the newly added information according to the path. poc file on it. The following particularly concise script:

#coding:utf-8
import them
import sys
with open(r'files.txt') as f: #Inside is the newly added vulnerability information in csv
    for line in f:
        dbid,file, description,date,author,use_type,platform,port = line.split('\t')
        name = 'exploit-database-master/'+file #Folder where all poc files are stored      
        n_name = 'file/'+file #Folder where the new poc file is stored
        path = os.path.split(n_name)[0] #Return the path where the newly added poc is stored
        if os.path.exists(path):
        	print 'exists'
        else:
        	os.makedirs(path) #Create a new path if the path does not exist
        open(n_name, "wb").write(open(name, "rb").read()) #Read the original poc and rewrite it to the new folder


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324896441&siteId=291194637