anduin revidoval tento gist 1 day ago. Přejít na revizi
1 file changed, 1 insertion, 3 deletions
send.sh
| @@ -10,9 +10,7 @@ RANDOM_STRING="SDQwjPd54R84tGaackbWmYNme4tmsD75" | |||
| 10 | 10 | # Your User-Agent | |
| 11 | 11 | USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" | |
| 12 | 12 | ||
| 13 | - | # !! Fill in the Referer and Origin from your "Copy as cURL" | |
| 14 | - | # !! These two headers are crucial for preventing 403 Forbidden errors | |
| 15 | - | REFERER_HEADER="https://hitools.hikvision.com/en/some-page-you-were-on" | |
| 13 | + | REFERER_HEADER="https://hitools.hikvision.com/HiToolsDesigner/" | |
| 16 | 14 | ORIGIN_HEADER="https://hitools.hikvision.com" | |
| 17 | 15 | # Check if 'X-Requested-With: XMLHttpRequest' is also in your 'Copy as cURL' | |
| 18 | 16 | X_REQ_WITH_HEADER="XMLHttpRequest" | |
anduin revidoval tento gist 1 day ago. Přejít na revizi
1 file changed, 90 insertions
send.sh(vytvořil soubor)
| @@ -0,0 +1,90 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | ||
| 3 | + | # --- 1. Configuration (Critical!) --- | |
| 4 | + | ||
| 5 | + | # These values are observed from your browser. They will likely expire! | |
| 6 | + | # When the script fails, you may need to re-capture these two values from your browser. | |
| 7 | + | FINGERPRINT="ZSbU9jU2AZWgnNagZ61vVua0RCZr46DT5eSwn8uHKsc8QFEFBhTVYPI7a1LWcrDAwOm%2F4AGv7rmTw%2F4xVTQqgA%3D%3D" | |
| 8 | + | RANDOM_STRING="SDQwjPd54R84tGaackbWmYNme4tmsD75" | |
| 9 | + | ||
| 10 | + | # Your User-Agent | |
| 11 | + | USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" | |
| 12 | + | ||
| 13 | + | # !! Fill in the Referer and Origin from your "Copy as cURL" | |
| 14 | + | # !! These two headers are crucial for preventing 403 Forbidden errors | |
| 15 | + | REFERER_HEADER="https://hitools.hikvision.com/en/some-page-you-were-on" | |
| 16 | + | ORIGIN_HEADER="https://hitools.hikvision.com" | |
| 17 | + | # Check if 'X-Requested-With: XMLHttpRequest' is also in your 'Copy as cURL' | |
| 18 | + | X_REQ_WITH_HEADER="XMLHttpRequest" | |
| 19 | + | ||
| 20 | + | ||
| 21 | + | # --- 2. Preparation --- | |
| 22 | + | ||
| 23 | + | # Create a secure temporary file to store cookies | |
| 24 | + | COOKIE_JAR=$(mktemp) | |
| 25 | + | ||
| 26 | + | # Ensure the cookie file is deleted on script exit | |
| 27 | + | trap "rm -f $COOKIE_JAR" EXIT | |
| 28 | + | ||
| 29 | + | # Your API URLs | |
| 30 | + | GET_SESSION_URL="https://hitools.hikvision.com/TSAPI/User?fingerprint=${FINGERPRINT}&r=${RANDOM_STRING}&platform=indepLink&area=Global" | |
| 31 | + | POST_PRODUCT_URL="https://hitools.hikvision.com/en/TSAPI/ESServe/v2/products" | |
| 32 | + | ||
| 33 | + | # Your JSON data | |
| 34 | + | JSON_PAYLOAD='{ | |
| 35 | + | "bool": { | |
| 36 | + | "or": { | |
| 37 | + | "term": [ | |
| 38 | + | { | |
| 39 | + | "key": "productBaseInfo.productSapId.keyword", | |
| 40 | + | "value": "311326558" | |
| 41 | + | } | |
| 42 | + | ] | |
| 43 | + | } | |
| 44 | + | }, | |
| 45 | + | "productBracket": true | |
| 46 | + | }' | |
| 47 | + | ||
| 48 | + | ||
| 49 | + | # --- 3. Step 1: Get Session --- | |
| 50 | + | ||
| 51 | + | echo "Getting session..." | |
| 52 | + | # -s: Silent mode | |
| 53 | + | # -L: Follow redirects | |
| 54 | + | # -c: (cookie jar) Write cookies to the $COOKIE_JAR file | |
| 55 | + | # We also need to add UA and Referer to this GET request to simulate a browser | |
| 56 | + | curl -s -L \ | |
| 57 | + | -A "$USER_AGENT" \ | |
| 58 | + | -H "Referer: $REFERER_HEADER" \ | |
| 59 | + | -H "Origin: $ORIGIN_HEADER" \ | |
| 60 | + | -H "X-Requested-With: $X_REQ_WITH_HEADER" \ | |
| 61 | + | -c "$COOKIE_JAR" \ | |
| 62 | + | "$GET_SESSION_URL" | |
| 63 | + | ||
| 64 | + | # Check if the cookie file is empty | |
| 65 | + | if [ ! -s "$COOKIE_JAR" ]; then | |
| 66 | + | echo "Failed to get session! Cookie file is empty." | |
| 67 | + | exit 1 | |
| 68 | + | fi | |
| 69 | + | ||
| 70 | + | echo "Session and Cookies saved to: $COOKIE_JAR" | |
| 71 | + | # You can inspect the cookies by uncommenting the next line | |
| 72 | + | # cat $COOKIE_JAR | |
| 73 | + | ||
| 74 | + | ||
| 75 | + | # --- 4. Step 2: POST Data Using the Session --- | |
| 76 | + | ||
| 77 | + | echo "POSTing data..." | |
| 78 | + | # -b: (cookie) Read cookies from the $COOKIE_JAR file | |
| 79 | + | curl -X POST \ | |
| 80 | + | -b "$COOKIE_JAR" \ | |
| 81 | + | -A "$USER_AGENT" \ | |
| 82 | + | -H "Content-Type: application/json" \ | |
| 83 | + | -H "Referer: $REFERER_HEADER" \ | |
| 84 | + | -H "Origin: $ORIGIN_HEADER" \ | |
| 85 | + | -H "X-Requested-With: $X_REQ_WITH_HEADER" \ | |
| 86 | + | -d "$JSON_PAYLOAD" \ | |
| 87 | + | "$POST_PRODUCT_URL" | |
| 88 | + | ||
| 89 | + | echo | |
| 90 | + | echo "Script execution finished." | |