AWD
加固-信息搜集
ipscan 扫描C段 – win Netdiscover – kali netdiscover -r 192.168.100.0/24 不能2层扫描。
如果有B段,nmap存活探测 , zenmap – 图形化界面 nestat nestat -pantu # kali -tnl -lntup ps -ef | grep apache # 找服务地址
WebserverScanner
收集操作记录,可能有历史mysql密码
history
history | grep mysql 查看其他用户的 history ls -al | grep history more .mysql_history C+F C+B
/var/log
whereis mysql # 找到位置 查看配置文件
重启网卡 /etc/init.d/network-manager systemctl restart NetworkManager
漏洞检测 27关
upload-labs 通关攻略 上传漏洞12345789 Svn git 源码泄露 Strus, jboss – K8飞刀 CMS, 参考 exp-lists 反序列化,badbash,heartbleed
Apache: conf/httpd.conf, /etc/httpd/conf/httpd.conf Redhat 系列 httpd – whereis httpd Ubuntu 服务是 Apache
Tomcat: conf/server.xlm, tomcat-users.xml Mysql: /etc/my.cnf 站点配置文件 conn.php inc.php config.php 利用 .htaccess 进行加固 php.ini 搜索 disable, 在 disable function = phpinfo,eval,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen
lampp重启 重启: /opt/lampp/lampp restart lampp/htdocs
Apache
httpd/conf 搜索 user
ServerSignature Off # 关闭服务器生成页面的页脚中版本信息 ServerTokens Prod # Prod 隐藏信息
conf 配置文件 修改 DocumentRoot 路径 禁止目录遍历 Options -Indexes FollowSymLinks 设置只监听 1.1.1.1 地址的 80 端口 Listen 1.1.1.1:80 禁用SSI 自定义错误信息 关键文件权限 使用命令“chmod 600 /etc/httpd/conf/httpd.conf” ⚫ 设置配置文件为属 主可读写,其他用户无权限
修改 Apache 配置文件 httpd.conf,添加以下行,以 php 为例:
⚫ <Directory "/var/www/html/upload">
⚫ <FilesMatch "\.php$">
⚫ Order allow,deny
⚫ Deny from all
⚫ </FilesMatch>
⚫ </Directory>
增加验证 用户名密码 htpasswd .htpasswd user1
进入网址后,F12开发者工具-网络–查看请求。
常用命令
文件打包 tar -cvf web.tar . 192.168.x.x/web.tar Ctrl+Shift+T 新建终端
seay 源代码审计, 导入后,点击 自动审计 WebshellKill - 查杀工具,自定义扫描 选择审查的地方。
ifconfig – Linux
配置ip ifconfig eth0 192.168.100.211 netmask 255.255.255.0 路由 route add default gw 192.168.5.1
route –Windows
route add 192.168.100.0/24 192.168.100.1
重置路由
netsh int ipv4 reset
route print — 路由会优先使用最后一条。
搜索文件中的字符串
grep -nr “strings”
Mysql 加固
mysqld
设置密码
select user, password, host from mysql.user(); update mysql.user set password=password(‘123456’) where user=’root’ 或 set password=password(‘123456’); set password for demo@’localhost’ = password(‘123456’); mysqladmin ***** 或 mysqladmin -u用户名 -p旧密码 password 新密码 或 mysqld –skip-grant-tables 回车 mysqladmin -u root password secret
FAQ
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”) mysqladmin -u root password secret -h 127.0.0.1 mysql -uroot -psecret
% 表示远程
查看状态 mysqld status
新用户授权
grant 权限 on . grant all on test.* grant all on . to demo@’%’ revoke all on . from demo@’%’ grant all on finecms.* to demo@’%’ identify by ‘demo’ flush privileges
配置文件
限制远程登录 bind-address=127.0.0.1
禁止读取主机上的文件 修改my.cnf 添加 set.variable=local-infile=0