asp.net Web site security from small start and prevention Summary _ practical skills

Source: Internet
Author: User
The following are examples of the ASP.net development website.

1, SQL injection vulnerability.

WORKAROUND: Use stored procedures, and do not use string concatenation of parameters. Simple ways to improve: using SqlHelper and Oledbhelper

2. Cross-site Scripting vulnerabilities

Workaround: "Default prohibit, explicit Allow" policy. Specific reference: Detection of potentially dangerous request.form value from the client, prohibit the submission of HTML tags (<> etc was escaped to <)

3, upload the vulnerability

Workaround: Prohibit the upload directory from running permissions. Only Read permission is given. Also prohibit uploading of illegal type files. Not only ASPX types, including many, even htm, HTML type files should not be directly uploaded to save.

4, the database connection account number, as far as possible uses the lowest privilege account number. You must not give administrator permissions.

If the hacker learned the password of the database.
Then we can execute arbitrary system commands.
For example: xp_cmdshell ' dir c:\ '
In addition, there are
Tasklist
Taskkill
PsList
PsKill
NET user
NET user Guest/active:yes
NET user hack Hack/add
NET user Hack/del
NET LOCALGRUOP Administrators Hack/add
Query user
Logoff 1
Aren't these orders scary? Oh. So be sure not to connect the Web database with Account Admin permissions.

5, User login. Do not store the user ID in a cookie to identify if the user is logged in. Because cookies can be modified. Please look at the modified cookie here to impersonate another user. NC HttpWatch uses the video tutorials, and Microsoft Forms Forms authentication and roles are generally sufficient.

6, if the Web site program used to read and write files, must be cautious, because the reading of the operation is likely to be exploited by hackers, such as a view of the image of the aspx file read Web.config, with a production template function to generate Trojans.

7. Make full use of verification code. Users login, comments, and so on may be submitted to spam where the use of authentication code, and have a secure authentication code. To prevent being violently cracked and to prevent web sites from being full of spam data.

8, the code to be rigorous, modify user data, modify user information to be associated with the user, such as update news set title= ' new title ' where Id= news number, here also add a limit: userid= user number, this can prevent a person to modify other people's news.

9, turn off the error display in Web.config. <customerrors mode= "RemoteOnly" defaultredirect= "404.aspx" ></customErrors>

The above is a procedural security issue, where you want to write where. There is no systematic collation.

Also, incidentally, the server security issue is mentioned.

1, open Windows Firewall, shut down the unused port. This is the most important thing. The less service you offer, the more secure your server will be.

2. Set a secure password. Complexity to reach a certain intensity. Change your password regularly. Passwords should not be leaked to others, including computer room administrators. If you need to tell the computer room personnel, to the computer room after the password immediately get rid of.

3, install the ARP firewall. The machine room ARP virus is very many, if in the ARP virus, the Light browsing website is not normal, may have the Trojan to follow. Serious on the entire website, the computer room are broken nets.

4, the appropriate installation of anti-virus software. (Norton, mccafés, etc.)

5, IIS shutdown unused services, such as ASP support, turn off the unused services: FTP,SMTP,POP3, and so on, modify the site root directory. Set directory permissions.

6, for various attacks, there are different countermeasures, such as CC attacks. Once encountered, Shenzhen, there are 5 consecutive IP machines on one of my video station launched CC attack, causing the site to open very slowly, beginning we do not know is being attacked, the program has loopholes, and constantly find the problem of the program. Later, through the server security management software, found that these IP in mischief, through the webmaster shielding IP access to several methods mentioned in the "Local Security Policy" method to screen out the 5 IP after the server back to normal, the site restored the speed of the past.

Common commands: iisapp-a,netstat-nao,tasklist,telnet xxx.xxx.xxx.xxx ports

7, remote management software do not use the default port, although the password is violent cracked and guessed may be very small, but always have a boring person to try. Create a pile of spam in the log. After modifying the port, no one tried to crack the password. Because he doesn't know what this port is for. Speaking of this, I think that the service to shut down, then the use of the server will be opened? That must be started, do not start who can not use, here is a limit, for example, my SMTP service only provides native use, then I from the firewall to 25 ports off, if my SQL Server is only for the local use. So I'm from the firewall, too. 1433 ports off. So outside can not connect, naturally there is no violence to crack the database password. Windows Firewall can also open a port for one IP. is still relatively strong.

Above a mess of talk a bunch of, hope to webmaster and program members have help, we can add my qq:4111852 exchange. I'm very welcome.

Finally said that the netizen was hanged the horse the solution proposal:

1, Backup good database, other data.

2. Remove all programs, including directories, to ensure that no files are left behind the back door.

3, if possible, check the server security, to ensure that the server is not built back door, such as super account, installed backdoor Trojan. In this case, how you modify your program is useless, someone can modify your program at any time.

4, another user mentioned the method, upload a static file test.html, visit to see if there are Trojans to eliminate network problems.

5, if 4, the confirmation is not a network problem, that is the file is Hung horse, all Programs Delete, upload their own security backup, restore data, check the database, to ensure that the Trojan is not in the database.

6, check the IIS log, see who has logged in the background, reference: IIS Log Analysis Video Tutorials

The thought is very messy, everybody will have a look

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.