Get the App
SLTechnology News&Howtos  ›  Network Security  › 

More than ten lines of Python code to get the poc added to the db library

Shulou Source: shulou.com Published: 2022-06-01 04:06:01 09月15日 Update

1. Background introduction

Due to the needs of the project and my hobbies, I download the compression package on the exploit-db library every month and update it to my own vulnerability platform. However, in the past, the entire folder of exploit was uploaded to the server through the remote desktop, because this folder is so large that it takes a long time to upload, so I just want to write a script to collect the new poc added last month.

two。 Use tools

Python2.7 's os and sys libraries

3. Script

First of all, the db library provides a particularly convenient way to have an excel file to store vulnerability information, including the file path of poc, so just put the new information in a txt text and regenerate the new poc file according to the path. The following is a particularly concise script:

# coding:utf-8import osimport syswith open (ringing files. Txt') as f: # contains the new 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 for all poc files n_name =' file/'+file # folder for new poc files path = os.path.split (n_name) [0] # returns the path if os.path.exists (path) for the newly added poc: Print 'exists' else: os.makedirs (path) # create a new path open (n_name) if the path does not exist "wb") .write (open (name, "rb") .read () # read the original poc and then rewrite it to the new folder

Tags: Files folders paths information vulnerabilities scripts simplicity personal tools platforms text methods servers desktops backgrounds good faceted projects medium-new long-term Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Linux Docker Apple