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(五) #76

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

DSScan(五) #76

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

Comments

@PyxYuYu
Copy link
Owner

PyxYuYu commented Jan 12, 2017

Although it rains, throw not away your watering pot.

0x01 DSScan

  • 表单函数 forms.py
    • 表单接受的数据要保存到数据库,需要用到 save 方法
      • 表单继承 forms.Form ,需要自写 save 方法
      • 表单继承 forms.ModelFormModelForm 具有 save 方法,能将表单中的数据保存至数据库
      • 所以,此处更应该用 forms.ModelForm ,表单与 SqlInjection 数据模型相对应
        • 这样的话,就不用自写 save 方法
           from django import forms
           from .models import SqlInjection
           
           class SqlInjectionForm(forms.ModelForm):
           
               class Meta:
          	     model = SqlInjection
          		 fields = ('target_url', )
    • 保存单个 URL 到数据库中,用上面的表单即可实现
    • 如果需要一次性保存多个 URL 到数据库中,就需要在数据模型中新建一张数据表,存储这些 URLS
  • 数据模型 models.py
    • 新建一个数据模型,用于保存多个 URLS
       class UrlList(models.Model):
           target_urls = models.TextField(null=True)
    • 同步到数据库
       python manage.py makemigrations
       
       python manage.py migrate
    • 创建了新的数据模型后,表单函数也要跟着改变,将 SqlInjection 改为 UrlList
       class UrlListForm(forms.ModelForm):
       
           class Meta:
      	     model = UrlList
      		 fields = ('target_urls', )
    • 相应的,视图函数中也要进行对应的变更
       from .forms import UrlListForm
       
       def url_sql(request):
    
         if request.method == 'POST':
             form = UrlListForm(request.POST)
             if form.is_valid():
      	     form.save()
         else:
             form = UrlListForm()
          return render(request, 'sqliscan/open.html', {'form': form})
    • 这样 URLS 即可保存至数据库中,其中模板文件 open.html 利用 <textarea> 来显示表单
  • 模板文件
    • open.html 表单部分,两个按钮,一个提交,一个扫描
       <form action="." method="post" class="form-horizontal" role="form">
          <div class="form-group col-group-sm">
              <div class="col-lg-8">
                  <textarea rows="3" class="form-control" placeholder="URLS" name="target_urls" required></textarea>
              </div>
          </div>
    
          {% csrf_token %}
    
          <button type="submit" class="btn btn-default" >
              <span class="col-lg-1"><span class="glyphicon glyphicon-import"></span></span>
          </button>
    
          <a href="/">
          <button type="submit" class="btn btn-default" >
              <span class="col-lg-1"><span class="glyphicon glyphicon-search"></span></span>
          </button>
          </a>
       </form>
    • task.html 模态框
      • 今天测试发现,不同任务模态框显示数据竟然一样,Google 查了后得知是之前生成的模态框对象数据未清楚导致,但是不管怎么样清楚都无效,所以就只能利用不同任务对应不同模态框来实现输出对应数据
      • 模态框由 data-target=#myModalid=myModal 两两对应,所以只需修改这两处即可
      <a href="#{{ task.task_id }}" data-toggle="modal" data-target="#{{ task.task_id }}">
          <span class="glyphicon glyphicon-arrow-down"></span>
      </a>
      <div class="modal fade" id="{{ task.task_id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog">
      <div class="modal-content">
          <div class="modal-header">
              <button data-dismiss="modal" class="close" type="button">
                  <span aria-hidden="true">×</span>
                  <span class="sr-only">Close</span>
              </button>
              <h4 class="modal-title">SCAN LOG</h4>
          </div>
          <div class="modal-body">
              {{ task.scan_log }}
          </div>
          <div class="modal-footer">
              <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
          </div>
      </div>
      </div>
      </div>
@PyxYuYu PyxYuYu added the DSScan label Jan 12, 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