curl does not log in to router - batch-file

curl "http://192.168.0.1/goform/login" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" -H "Origin: http://192.168.0.1" -H "Upgrade-Insecure-Requests: 1" -H "DNT: 1" -H "Content-Type: application/x-www-form-urlencoded" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" -H "Referer: http://192.168.0.1/login.asp" -H "Accept-Language: en-US,en;q=0.9" -H "Cookie: alertWindowStatus=donotshow" --data-raw "loginChallenge=censored just in case&loginUsername=censored&loginPassword=censored" --insecure --location
This is the code for curl that google gave me using networking monitoring when I logged in to my router. I would want curl to login to my router and change a few settings (cmd curl) in a batch file. However, even when I use what chrome gave me when I logged in, I still end up at the login screen. Why does it not curl back the home screen for my router instead of the login screen?
I got this method from: https://superuser.com/questions/1423850/how-can-i-use-curl-to-login-into-non-digest-login-sites

Related

Bugzilla 5.0 REST API Authentication in headers

Using the Bugzilla 5.0 REST API, how do I send the API key in a header?
The following works with a 200 response and creates a bug:
curl -Ski -X POST -H "Content-Type: application/json"
-H "Accept: application/json"
--data "#$HOME/bug_attrs.json"
"https://fmd-bugzil-01tst.vrt.sourcefire.com/rest/bug?Bugzilla_api_key=ibMexQ7suwgyiYNskgxgBDqrXGLV5Jkogj1KSYL0"
But sending it in the header returns a 401:
curl -Ski -X POST -H "Content-Type: application/json"
-H "Accept: application/json"
-H "X-BUGZILLA-API-KEY: ibMexQ7suwgyiYNskgxgBDqrXGLV5Jkogj1KSYL0"
--data "#$HOME/bug_attrs.json"
"https://fmd-bugzil-01tst.vrt.sourcefire.com/rest/bug"
How do I send the API Key in the headers instead of the Query string?
I think you are using stable version of Bugzilla, version 5.0.4, according to the documentation for Rest API 5.0.4, it does not support X-BUGZILLA-API-KEY header for authentication.
However, latest version 5.1.2 has support for allowing api key in the header.
Alternatively, authentication credentials can be provided via one of
the following headers:
X-BUGZILLA-LOGIN
X-BUGZILLA-PASSWORD
X-BUGZILLA-API-KEY
X-BUGZILLA-TOKEN
Credentials passed as part of the query string take
precedence over the header credentials.

Authenticated Rest calls in Zeppelin

I have enables authentication in Zeppelin. I am able to authenticate Zeppelin from curl:
curl -i --data 'userName=admin&password=admin' -X POST http://ip_address:port/api/login
It is giving me response properly with JSESSIONID.
How can I use the same session in my next API calls like
http://ip_address:port/api/notebook
Thanks.
Write the response cookies to local file during login api call
curl -c cookies.txt -i --data 'userName=admin&password=admin' -X POST http://ip_address:port/api/login
and pass the cookies to next API calls
curl -b cookies.txt http://ip_address:port/api/notebook
Example for run note
curl -i -b 'JSESSIONID=ad51301f-a13b-4b8d-a6c7-b684dc453f8f; Path=/; HttpOnly' -X POST -H "Content-Type: application/json" http://ip_address:port/api/notebook/job/note_id

Executing simultaneous curl calls from bat script

I put together a basic batch script that grabs words from a txt file and executes curl on three urls with the search_word being the search paramater. The results are placed in a html page. However, I am running into an issue.. it a slow process. How can I execute the curl simultaneously for the three urls?
#echo off
setlocal enabledelayedexpansion
set OUTPUT_FILE=test.html
for /f %%i in (search_words.txt) do (
curl -k -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" http://www.example.com/search?q=%%i >>%OUTPUT_FILE%
curl -k -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" http://www.example2.com/search?q=%%i >>%OUTPUT_FILE%
curl -k -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" http://www.example3.com/search?q=%%i >>%OUTPUT_FILE%
)

How can I get result from curl in Apache Camel?

How can I get result from curl in Apache Camel?
Apache Camel have some "curl" component for running curl?
or I only need use camel-exec?
and then I need parse json and "station":"\u041a\u0438\u0457\u0432-\u041f\u0430\u0441\u0430\u0436\u0438\u0440\u0441\u044c\u043a\u0438\u0439"
how to get normal text from this json encoding in Apache Camel?
I have no expirience with Apache Camel..
curl 'http://booking.uz.gov.ua/purchase/search/' -H 'GV-Token: 502c55405bfb82fa16e08278d934c5f1' -H 'Origin: http://booking.uz.gov.ua' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8,ru;q=0.6,uk;q=0.4' -H 'Connection: keep-alive' -H 'Cookie: _gv_sessid=3lt3g4org56quapm20ogqs9n33; _gv_lang=uk; HTTPSERVERID=server1; __utmt=1; __utma=31515437.700625198.1438102950.1440172017.1440176787.29; __utmb=31515437.1.10.1440176787; __utmc=31515437; __utmz=31515437.1439982958.17.2.utmcsr=uz.gov.ua|utmccn=(referral)|utmcmd=referral|utmcct=/passengers/reservation_purchase_travel_documents/' -H 'GV-Ajax: 1' -H 'GV-Screen: 1280x800' -H 'GV-Referer: http://booking.uz.gov.ua/' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: */*' -H 'Referer: http://booking.uz.gov.ua/' -H 'GV-Unique-Host: 1' -H 'DNT: 1' --data 'station_id_from=2218020&station_id_till=2200001&station_from=%D0%9A%D0%BE%D0%B2%D0%B5%D0%BB%D1%8C&station_till=%D0%9A%D0%B8%D1%97%D0%B2&date_dep=24.08.2015&time_dep=00%3A00&time_dep_till=&another_ec=0&search=' --compressed
As a first step, you'll have to fetch the document at the given URL via an HTTP GET request. You could do this in the scope of an Apache Camel route by enriching the exchange but you would have to trigger the route somehow. As far as I know, for HTTP there is no scheduled polling consumer component in Camel. That would be the requirement to simply create a route like 'from("http:...")'.
A simple approach can be to use the component "http4" in order to request the document with an ConsumerTemplate. This can be created via the CamelContext (CamelContext.createConsumerTemplate()). Find an example for this in the Apache Camel tests. Look at the lines with "consumer.receiveBody(...)".
In order to work on the JSON payload, you can use Camel's JSON tools like the JsonPath language.
If you used a ConsumerTemplate to fetch the document, you have to create a route like the following (taken from Camel docs) and trigger it with a ProducerTemplate:
from("direct:start")
.choice()
.when().jsonpath("$.store.book[?(#.price < 10)]")
.to("jms:queue:book.cheap")
.when().jsonpath("$.store.book[?(#.price < 30)]")
.to("jms:queue:book.average")
.otherwise()
.to("jms:queue:book.expensive")
In the example shown you'd send the body to the endpoint "direct:start" by utilizing a ProducerTemplate.

Full import URL DataImportHanlder

I have configured my solr data import handler, and now want do to full import. On Solr Wiki page I have found that one way to check my config is:
Hit _http://local_host:8983/solr/db/dataimport with a browser to verify the configuration.
Is this correct and what would parameter "db" be in previous URL? I assume it is one of parameters I entered somewhere earlier, but it is not clear which. It is not written on the page.
Thanks!
Url you are looking for is:
http://localhost:8983/solr/{collection_name}/dataimport?command=full-import
Tutorial:
http://solr.pl/en/2010/10/11/data-import-handler-%E2%80%93-how-to-import-data-from-sql-databases-part-1/
http://solr.pl/en/2010/11/01/data-import-handler-%E2%80%93-how-to-import-data-from-sql-databases-part-2/
http://solr.pl/en/2010/11/22/data-import-handler-%E2%80%93-how-to-import-data-from-sql-databases-part-3/
This command is for Full-import via URL.
curl -X POST \
http://local_host:8983/solr/db/dataimport \
-H 'Accept: application/json, text/javascript, */*; q=0.01' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Origin: http://localhost:8983' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' \
-H 'X-Requested-With: XMLHttpRequest' \
-d 'command=full-import&clean=true&commit=true&wt=json&indent=true&verbose=false&optimize=false&debug=false'

Resources