:~> whoami
Alireza Rezaie
Twitter :
Blog :
@Ralireza11
MrBug.ir
Memory Management
Common Attacks
Input validation
Input validation
Input validation - Best practice
Input validation - Best practice
Input validation - Best practice
Input validation - Best practice
allow_values = [ 1, 2, 3, 4]
if input in allow_values:
return true
else
return false
Input validation - Best practice
Input validation - Best practice
auth - Best practice
auth - Best practice
auth - Best practice
auth - Best practice
auth - Best practice - Storing password
auth - Best practice
auth - Best practice
auth - Best practice
auth - Best practice
Error Handling and Logging :
Error Handling and Logging - Best practices :
Error Handling and Logging - Best practices :
Error Handling and Logging - Best practices :
Error Handling and Logging - Best practices :
isAuthorized(), isAuthenticated(), validate(), ...
Error Handling and Logging - Best practices :
isAdmin = true;
try {
codeWhichMayFail();
isAdmin = isUserInRole( "Administrator" );
}
catch (Exception ex)
{
log.write(ex.toString());
}
isAdmin = false;
try {
codeWhichMayFail();
isAdmin = isUserInrole( "Administrator" );
}
catch (Exception ex)
{
log.write(ex.toString());
}
Error Handling and Logging - Best practices :
Error Handling and Logging - Best practices :
Sequencing failure
Excessive use
Data changes
Fraud and other criminal activities
Suspicious, unacceptable or unexpected behavior
Modifications to configuration
Application code file and/or memory changes
Error Handling and Logging - Best practices :
When
Error Handling and Logging - Best practices :
Memory Management
Brute Force
Man-In-the-Middle
SQL Injection
RAT
Code Injection
Command Injection
XSS
CSRF
Social Engineering
SELECT id FROM products WHERE productid=9999 OR 1=1
SELECT * FROM products WHERE id=1 AND 1>(SELECT count(*) FROM information)
SELECT * FROM products
SELECT name FROM products WHERE id=1 UNION SELECT 1 FROM table
SELECT * FROM products WHERE productid=1; DELETE FROM products
Validation checks if the input meets a set of criteria (such as a string contains no standalone single quotation marks). Sanitization modifies the input to ensure that it is valid (such as doubling single quotes). |
$myvar = "varname";
$x = $_GET['arg'];
eval("\$myvar = \$x;");
$ > whoami & echo "test"
Avoid calling OS commands directly
mkdir() vs system("mkdir /dir_name").
Validating against a whitelist of permitted values
The input contains only alphanumeric characters
BufferOverflow
...
char buf[BUFSIZE];
cin >> (buf);
...
cross-site-scripting
Encoding
Validation
HTTP-only
No untrusted sources
No inline resources
No eval
The art of humen hacking