Posts

RESTful API

Image
RESTful API In this blog post I am going to show how to create a resource server api. First we need to understand how it works. We can use exiting authorization sever or like there you can create your own authorization sever  and resource server both in a single api. Sample code is uploaded to my github  LINK : "     " This is written using node.js. In order to run this on your computer you have to have node.js installed on your comouter. app.js  This app tuns on port 4000. You can give any port number here.There are two endpoints which  I have created in this. One to get the access token which is "/oauth/token" and the other one is to get resources which is "/profile". As resources I have hard-coded one value which is name ("pasan") and this comes as a JSON object model.js (username = test, password = test)   All the functions that handle requests from client are written here. Run ...

Cross Site Request Forgery (METHORD 02)

Image
Cross Site Request Forgery (METHOD 02) In last post Cross Site Request Forgery (Method 01) we discussed how to achieve SCRF attack protection using synchronized token pattern method. with this post lets see how to do it using double-submitted cookie pattern  Referring to above diagram, in double-submitted cookies (for the session and for the CSRF token) are stored in the web browser. In previous method we stores CSRF token values on the sever side. here it not the way we do it. Sample website was created and you can find it in my Github  LINK : "    https://github.com/PasanRS/Cross-Site-Request-Forgery-METHORD-02-    " index.php once this page gets loaded on the web browser user sees a simple login form. Username and password are hard-coded in the code. as in previous example too. result.php As you can see two cookies are stored on the browser. These cookies have 1 year expiration time an...

Cross Site Request Forgery (METHORD 01)

Image
Introduction to Cross Site Request Forgery Cross-Site Request Forgery ( CSRF ) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated.  CSRF  attacks specifically target state-changing requests, not theft of data since the attacker has no way to see the response to the forged request. In this post you can learn  how CSRF can be used to protect your own website by generating Cross-Site Request Forgery Tokens in server side and validating them before respond to any client request.  You can find sample website source code is uploaded to the GitHub and you can download it from there. LINK : "  https://github.com/PasanRS/Cross-Site-Request-Forgery-METHORD-01-   " What does this website do? User logs into the website using his/her credentials (username and password are hardcoded "pasan", "pasan"). Upon the log in a session will be created and the session id w...

SQL Injection Countermeasures

SQL Injection Countermeasures SQL injection is kinda complex vulnerability and usually applying a fix will differ on which type of application you are developing. By the way instead of its complexity and different types of injection methods SQL injection is one of the easiest to counter. Following are some measures that can be used against SQL injection attack. 1. As told earlier SQL injection attacks occurs due to non-sanitized input. So our first step would be sanitizing input. At developer level build application which explicitly escapes single quotes and apostrophe, do not validate input of expression type for example, 1 + 1, x+ y etc. By sanitizing input by above method you'll be able to stop SQL injection since application will not accept malicious input. 2. The second solution at developer level is to use Application Programming Interface (API's) which disallow SQL injection. Today nearly every web application development tool has an API...

Attacks Against Weak Token Generation

Attacks Against Weak Token Generation During our last post to this we discusses about basics of Session Management Attack which is also known as session hacking. In this post we will have a look on how you can attack weak token generation method to attack session management. Following are most common methods of generating weak tokens, Using meaningful tokens Predictable token generation Adding time dependent variations in tokens Now some important things before we discus real hack steps. In applications that use standard cookie mechanism for transmitting session tokens, it is easy to identify which item of data contains the token. In other cases it needs real brain work to identify them. Many web developers add extra tokens to cookies to fool hackers for example an application might add 14 tokens to yours browser's store, out of which only six are responsible for session management no matter what value other eight have only six of them will hand...

SSL And TLS Attacks | Weak Ciphers

Image
SSL And TLS Attacks | Weak Ciphers Both SSL and TLS protocols works on the basis of Public Key Infrastructure (PKI) and commonly includes key exchange algorithm to handle security. Apart from just CA authority the strength of SSL cipher depends on length of key, encryption algorithm used to encipher data and Message Authentication Code (also known as SSL MAC ). In this post we will have our look on how key length could effect on cipher strength. So depending on the length of initial key generated for data exchange during SSL and TLS communication, ciphers can be divided into following categories. Null Security Ciphers: As name suggests these ciphers do not provide any security since there's no encryption. Weak Security Ciphers: All ciphers with key length less than 128 bits fall under this category. Ciphers using Diffie Hellman algorithm for key exchange are also considered as weak security ciphers since they are vulnerable to man-in-the-midd...

Must Read Before You Buy Spyware

Image
Must Read Before You Buy Spyware Hello visitor, if you are here then surely you are planning to buy spyware and you stopped by just to to know what I want to tell you before you buy one. First of all if you are too lazy to read this article completely because it is little lengthy or you don't want to waste your half second rolling your finger on your mouse and scroll down then please close this window and leave immediately because reading this article incomplete would be good enough to not reading it. There are different reasons for which different people buy spywares . Following are some of them, Spying and monitoring someone Hacking password To put parental control over child's online activity Spy or monitor your love or life partner for cheating on you Spy and monitor employee Controlling and restricting employee's internet abuse during office hours Monitor and restrict network activity of your Local Area Network (LAN) ...