Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSScan(七) #78

Open
PyxYuYu opened this issue Jan 15, 2017 · 0 comments
Open

DSScan(七) #78

PyxYuYu opened this issue Jan 15, 2017 · 0 comments
Labels

Comments

@PyxYuYu
Copy link
Owner

PyxYuYu commented Jan 15, 2017

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

0x01 DSScan

  • 整个项目的基本框架已经确定了,只差最重要的逻辑尚未实现
    • 最重要的逻辑也就是将 SqlInjection 数据表中的 target_url 提交至 SqlmapApi 中进行查询,最后将返回的一系列数据又保存至 SqlInjection 数据表中
    • 将这个调用 SqlmapApi 进行扫描的逻辑从视图函数 views.py 中单独出来作为一个模块,以便以后维护,更新
  • 所以,在 views.py 视图函数的同级目录新建 sqls.py
    • SqlmapApi 相关函数都写在这个 sqls.py 模块中
    • 多线程也写在里面,多线程的话,需要利用队列 Queue
      • 队列 Queue 是用于保存 target_url,所以这个多线程函数必须有一个参数 url_queue
      • 多线程检测的时候,SqlmapApi 扫描到的数据必须保存到数据库中
# 创建多线程
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()
@PyxYuYu PyxYuYu added the DSScan label Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant