import requests
import pymongo
import bs4


class PacketStormSecurity:

    def __init__(self):
        self.client = pymongo.MongoClient('mongodb://localhost:27017/')
        self.db = self.client['THT']
        self.col = self.db['packetstormsecurity']
        self.page = 2

    def Script(self):

        for page_n in range(1, self.page + 1):
            resp = requests.get(
                'https://www.packetstormsecurity.com/files/tags/exploit/page' + str(page_n),
                headers={'User-Agent': 'Mozilla/5.0'}
            ).text

            parser = bs4.BeautifulSoup(resp, 'html.parser')
            exploits = parser.find_all('dl', {'id': True})

            for exploit in exploits:
                exploit_id = exploit['id']

                if len(list(self.col.find({'exploit_id': exploit_id}))) == 0:
                    title = exploit.find('dt').find('a').text
                    date = exploit.find('dd', {'class': 'datetime'}).find('a').text
                    detail = exploit.find('dd', {'class': 'detail'}).text
                    author = exploit.find('dd', {'class': 'refer'}).find('a', {'class': 'person'})
                    cve = exploit.find('dd', {'class': 'cve'})
                    download_link = 'https://packetstormsecurity.com' + exploit.find('dd', {'class': 'act-links'}).find('a')['href']

                    if author is not None:
                        author = author.text

                    if cve is not None:
                        cve = cve.find('a').text

                    data = {
                        'title': title,
                        'date': date,
                        'detail': detail,
                        'author': author,
                        'cve': cve,
                        'download_link': download_link,
                        'exploit_id': exploit_id
                    }
                    self.col.insert_one(data)

if __name__ == '__main__':
    
    App = PacketStormSecurity()
    print("PacketStormSecurity Exploit Bilgileri Çekiliyor.")
    App.Script()
    print("İşlem Tamamlandı.")
import requests
import pymongo
import bs4


class PacketStormSecurity:

    def __init__(self):
        self.client = pymongo.MongoClient('mongodb://localhost:27017/')
        self.db = self.client['THT']
        self.col = self.db['packetstormsecurity']
        self.page = 2

    def Script(self):

        for page_n in range(1, self.page + 1):
            resp = requests.get(
                'https://www.packetstormsecurity.com/files/tags/exploit/page' + str(page_n),
                headers={'User-Agent': 'Mozilla/5.0'}
            ).text

            parser = bs4.BeautifulSoup(resp, 'html.parser')
            exploits = parser.find_all('dl', {'id': True})

            for exploit in exploits:
                exploit_id = exploit['id']

                if len(list(self.col.find({'exploit_id': exploit_id}))) == 0:
                    title = exploit.find('dt').find('a').text
                    date = exploit.find('dd', {'class': 'datetime'}).find('a').text
                    detail = exploit.find('dd', {'class': 'detail'}).text
                    author = exploit.find('dd', {'class': 'refer'}).find('a', {'class': 'person'})
                    cve = exploit.find('dd', {'class': 'cve'})
                    download_link = 'https://packetstormsecurity.com' + exploit.find('dd', {'class': 'act-links'}).find('a')['href']

                    if author is not None:
                        author = author.text

                    if cve is not None:
                        cve = cve.find('a').text

                    data = {
                        'title': title,
                        'date': date,
                        'detail': detail,
                        'author': author,
                        'cve': cve,
                        'download_link': download_link,
                        'exploit_id': exploit_id
                    }
                    self.col.insert_one(data)

if __name__ == '__main__':
    
    App = PacketStormSecurity()
    print("PacketStormSecurity Exploit Bilgileri Çekiliyor.")
    App.Script()
    print("İşlem Tamamlandı.")