Guest User

Scan for wp-toolkit injected/vulnerable rewrites in nginx conf

a guest
May 13th, 2026
171
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.00 KB | Cybersecurity | 0 0
  1. #!/bin/bash
  2.  
  3. # Ensure script is run as root
  4. if [ "$EUID" -ne 0 ]; then
  5.   echo "Error: Please run as root."
  6.   exit 1
  7. fi
  8.  
  9. RUN_DIR="$(pwd)"
  10. RAW_DUMP="${RUN_DIR}/nginx_assembled_tree.txt"
  11. MAIN_CONF="/etc/nginx/nginx.conf"
  12.  
  13. echo "========================================================================="
  14. echo "Assembling Active Nginx Configuration Tree (No Compiler Check)..."
  15. echo "Target Folder: ${RUN_DIR}"
  16. echo "========================================================================="
  17.  
  18. if [ ! -f "$MAIN_CONF" ]; then
  19.   echo "Error: Master file $MAIN_CONF not found."
  20.   exit 1
  21. fi
  22.  
  23. # Recursive function to mimic Nginx's include engine safely
  24. resolve_includes() {
  25.   local target_file="$1"
  26.   if [ -f "$target_file" ]; then
  27.     echo "## FILE_START: $target_file"
  28.    
  29.     while IFS= read -r line || [ -n "$line" ]; do
  30.       # Clean trailing/leading spaces
  31.       local clean_line=$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
  32.      
  33.       # If the line is an include directive, resolve its wildcards
  34.       if [[ "$clean_line" =~ ^include[[:space:]] ]]; then
  35.         # Strip 'include' and the trailing semicolon
  36.         local include_path=$(echo "$clean_line" | awk '{print $2}' | tr -d ';')
  37.        
  38.         # Expand wildcards natively via bash array matching
  39.         for expanded_file in $include_path; do
  40.           if [ -f "$expanded_file" ]; then
  41.             resolve_includes "$expanded_file"
  42.           fi
  43.         done
  44.       else
  45.         echo "$line"
  46.       fi
  47.     done < "$target_file"
  48.    
  49.     echo "## FILE_END: $target_file"
  50.   fi
  51. }
  52.  
  53. # Generate raw assembled configuration tree
  54. resolve_includes "$MAIN_CONF" > "$RAW_DUMP"
  55.  
  56. echo "Structure mapping complete. Analyzing for CVE-2026-42945..."
  57. echo "-------------------------------------------------------------------------"
  58.  
  59. VULN_COUNT=0
  60. CURRENT_FILE="Master nginx.conf Scope"
  61.  
  62. # Context trackers
  63. HAS_UNNAMED_REWRITE_WITH_QS=0
  64. HAS_STACKED_DIRECTIVE=0
  65. REWRITE_LINE=0
  66. REWRITE_CONTENT=""
  67. STACKED_LINE=0
  68. STACKED_TYPE=""
  69.  
  70. LINE_NUM=0
  71. while IFS= read -r RAW_LINE; do
  72.   ((LINE_NUM++))
  73.  
  74.   CLEAN_LINE=$(echo "$RAW_LINE" | tr -d '\r' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
  75.  
  76.   # Catch file boundaries from our recursive function
  77.   if [[ "$CLEAN_LINE" =~ ^##[[:space:]]FILE_START:[[:space:]] ]]; then
  78.     CURRENT_FILE=$(echo "$CLEAN_LINE" | awk '{print $3}')
  79.     continue
  80.   fi
  81.  
  82.   # Skip whitespace and comments
  83.   [[ "$CLEAN_LINE" =~ ^# ]] && continue
  84.   [[ -z "$CLEAN_LINE" ]] && continue
  85.  
  86.   # Match unnamed rewrite rules containing a literal '?'
  87.   if [[ "$CLEAN_LINE" =~ ^rewrite[[:space:]] ]] && [[ "$CLEAN_LINE" == *"?"* ]] && [[ "$CLEAN_LINE" != *"(?<"* ]]; then
  88.     HAS_UNNAMED_REWRITE_WITH_QS=1
  89.     REWRITE_LINE=$LINE_NUM
  90.     REWRITE_CONTENT=$CLEAN_LINE
  91.   fi
  92.  
  93.   # Match stacked target blocks inside the same context scope
  94.   if [[ "$CLEAN_LINE" =~ ^(set|if|rewrite)[[:space:]] ]]; then
  95.     if [ "$LINE_NUM" -ne "$REWRITE_LINE" ]; then
  96.       HAS_STACKED_DIRECTIVE=1
  97.       STACKED_LINE=$LINE_NUM
  98.       STACKED_TYPE=$(echo "$CLEAN_LINE" | awk '{print $1}')
  99.     fi
  100.   fi
  101.  
  102.   # Scope evaluation and state reset
  103.   if [[ "$CLEAN_LINE" == *"}"* ]]; then
  104.      if [ $HAS_UNNAMED_REWRITE_WITH_QS -eq 1 ] && [ $HAS_STACKED_DIRECTIVE -eq 1 ]; then
  105.         ((VULN_COUNT++))
  106.         echo "[!] STRUCTURAL THREAT DETECTED IN CONFIG TREE"
  107.         echo "    File Reference: $CURRENT_FILE"
  108.         echo "    Vulnerable Line: $REWRITE_CONTENT"
  109.         echo "    Trigger Neighbor: Stacked ($STACKED_TYPE) on line $STACKED_LINE of stream"
  110.         echo "-------------------------------------------------------------------------"
  111.      fi
  112.      HAS_UNNAMED_REWRITE_WITH_QS=0
  113.      HAS_STACKED_DIRECTIVE=0
  114.   fi
  115.  
  116. done < "$RAW_DUMP"
  117.  
  118. echo "========================================================================="
  119. echo "Analysis completed."
  120. echo "Total vulnerable blocks identified: $VULN_COUNT"
  121. echo "========================================================================="
  122.  
  123. # Clean up raw stream map file
  124. rm -f "$RAW_DUMP"
  125.  
  126.  
Advertisement
Comments
  • User was banned
  • User was banned
  • Mekmixor
    117 days
    # CSS 0.84 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1ifNm-s74mX7GChaEzSJ1dVQCy1SrSxlMVRYi8ys0rgQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • User was banned
Add Comment
Please, Sign In to add comment