PyxYuYu / MyBlog

记录和分享学习的旅程!
286 stars 101 forks source link

DSScan(七) #78

Open PyxYuYu opened 7 years ago

PyxYuYu commented 7 years ago

A good book is the best of friends, the same today and forever.

0x01 DSScan

# 创建多线程
class ScanThread(Thread):

    def __init__(self, url_queue):
        Thread.__init__(self)
        self.url_queue = url_queue

    def run(self):
        while True:
            if self.url_queue.empty(): break
            url_now = self.url_queue.get()
            print url_now
            task = SqlInjection.objects.get(target_url=url_now)
            resp_json = task_new()
            task_id = resp_json['taskid']
            task.task_id = task_id
            if resp_json['success']:
                print 'Set options...'
                option_json = option_set(task_id, url_now)
                if option_json['success']:
                    print 'Options are setted, start scan...'
                    start_json = scan_start(task_id, url_now)
                    # print start_json
                    start_time = time.time()
                    # print start_time
                    print 'Scanning...'
                    if start_json['success']:
                        while True:
                            status_json = scan_status(task_id)
                            # print status_json
                            task.scan_status = status_json['status']
                            if status_json['status'] != 'terminated':
                                time.sleep(10)
                            else:
                                # print status_json
                                print 'Scan is finished.'
                                # print task_id
                                data_json = scan_data(task_id)
                                # print data_json
                                if data_json['data'] == []:
                                    print 'There is no SQL Injection.'
                                else:
                                    print 'Data is ...'
                                    print data_json['data']
                                    # sql_list.append(url_now)
                                task.scan_data = data_json['data']
                                task_delete(task_id)
                                print 'Delete task.'
                                break
                            # print time.time()
                            if time.time() - start_time > 3000:
                                print 'No response.'
                                scan_stop(task_id)
                                scan_kill(task_id)
                                task_delete(task_id)
                                break
                    else:
                        print 'Task Error.'
            self.url_queue.task_done()
            task.save()