Aller au contenu
mprinfo

besoin aide connection routeur 4g Huawei

Recommended Posts

besoin aide connection routeur 4g Huawei

 

Je viens enfin de réussir a me connecté a l'api de mon routeur E5186

je récupère la SessionID et le Token

:http://192.168.8.1/api/webserver/SesTokInfo

<?xml version="1.0" encoding="UTF-8"?>
<response>
<SesInfo>SessionID=JeKxkiXRYojMr/K+dxK0fRL0s+weG1v2wAm79swD1JFv/Ne+1hW3EQCGaJAJf8RGnmqbo7Ij6doAmKzzEzaSS3PqY2suMcucysr2ZpWQanvGcojzA/GEhZEskYdgQL+g</SesInfo>
<TokInfo>y3o/pi/wOJrPC75N59B44OiUwRf+QJL9</TokInfo>
</response>

voici le code pour la home center 3

 function QuickApp:SessionID()
    if self.cookie == nil then
        print("/api/webserver/SesTokInfo")
        self.http:request(self.controller .. "api/webserver/SesTokInfo", {
             options = {
                checkCertificate = false,
                method = 'GET',
            },
            success = function(response)
                --print(json.encode(response.data))
                if response.status == 200 then
                   self.cookie = response.data
                   local len = string.len(self.cookie)
                   print(len) --277
                   self.Token = string.sub(self.cookie, 221, 252)--SesInfo
                   self.cookie = string.sub(self.cookie, 62, 199)--TokInfo
                   --self.cookie = string.sub(self.cookie, 72, 199)
                   print("Cookie : ",self.cookie)
                   print("Token : ",self.Token)
                   --self:loginUnifi(self.cookie)
                   --self:test(self.cookie)
                end
            end,
            error = function(error)
                self.cookie = nil
                self:error("checkTitreUnifi() échoué: ", json.encode(error))
                self:updateView("Titre", "text", "Controleur UNIFi - checkVersionUnifi() échoué: "..json.encode(error))
            end
        })
    end    
end

j'ai 2 variables :

self.cookie (SessionID)
self.Token (TOKEN)
 
Avec ces 2 variables j'arrive a faire des GET pour récupérer les infos qui n'ont pas besoin d'authentification
 
 function QuickApp:API(adresse)
    if self.cookie ~= nil then
        print("/device/basic_information", self.cookie )
        self.http:request(self.controller..adresse, {
             options = {
                checkCertificate = false,
                method = 'GET',
                headers = {
                    ['Cookie'] = self.cookie ,
                    ["content-type"] = "text/xml", 
                    ['__RequestVerificationToken'] = self.Token
                    }
            },
            success = function(response)
                print(json.encode(response.data))
                if response.status == 200 then
                   print(response.data)
                end
            end,
            error = function(error)
                self.cookie = nil
                self:error("checkTitreUnifi() échoué: ", json.encode(error))
                self:updateView("Titre", "text", "Controleur UNIFi - checkVersionUnifi() échoué: "..json.encode(error))
            end
        })
    end    
end

j'appele ces fonctions comme ceci

 

    self:SessionID() 

    fibaro.setTimeout(2 * 1000, function()
        print("-----------------------------------cradle")
        self:API("api/cradle/status-info") -- adresse mac "1 901 5 0 BC:25:E0:FA:C6:E5" 
        print("-----------------------------------device")
        self:API("api/device/autorun-version")                 -- "22.001.07.00.03" 
        self:API("api/device/basic_information")               -- version IU web + logiciel "LTE cpe 0 16.100.02.00.03 21.316.01.00.00" 
        self:API("api/device/device-feature-switch")           -- 0 1 
        self:API("api/device/information")                     ---100003 -- il faut une authentification
        print("-----------------------------------dialup")
        self:API("api/dialup/connection")-                     -- 0600015001
        self:API("api/dialup/mobile-dataswitch")               -- 1
        print("-----------------------------------global")   
        self:API("api/global/module-switch")                   -- 0 1 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 1 0 0 0 0 
        print("-----------------------------------language")
        self:API("api/language/current-language")              -- fr
        print("-----------------------------------monitoring")   
        self:API("api/monitoring/check-notifications")         -- UnreadMessage = 0 SmsStorageFull = 0 OnlineUpdateStatus = 14
        self:API("api/monitoring/converged-status")            -- SimState = 257 SimLockEnable = 0 CurrentLanguage = fr-fr
        self:API("api/monitoring/status")                      -- 901 2 101 3 0 0 '10.229.66.187' '172.20.2.39' '172.20.2.10' 0 64 64 2 1 1 101 5 0 1 cpe 0 1 
        self:API("api/monitoring/traffic-statistics")          -- 8743 1637862 79800 0 0 1637862 79800 8743 1
        print("-----------------------------------net")
        self:API("api/net/current-plmn")                       -- 0 F SFR SFR 20810 7 
        self:API("api/online-update/upgrade-messagebox")       -- 1
        self:API("api/pin/status")                             -- 257 258 3 10 
        self:API("api/redirection/homepage")                   -- 0
        self:API("api/security/upnp")                          ---100003 il faut une authentification
        self:API("api/sms/sms-list")                           ---100005        
        self:API("api/user/login")                             ---100006
        self:API("api/user/remind")                            -- 1
        self:API("api/user/session")                           -- ok
        self:API("api/user/state-login")                       -- State = -1 Username = "admin" password_type = 4
        self:API("api/wlan/basic-settings")                    -- Routeur2G 0 0 ALL b/g/n 0 100 32 1 2346 2347 1 100 1 0 0 1 1 600 0 0 0
        self:API("api/wlan/multi-switch-settings")
        self:API("api/wlan/wifi-feature-switch")
        self:API("api/net/net-mode")
        self:API("config/lan/config.xml")                      -- config lan
        self:API("config/global/config.xml")
        self:API("config/global/net-type.xml")
        self:API("config/pcassistant/config.xml")
        self:API("config/deviceinformation/config.xml")

    end)

On voit que j'arrive a récuperer une grande partie des infos sauf celle qui on besoin d'une authentification

 

Le mot de passe et de type 4

 

donc il faut base64 et SHA256

 

j'ai trouver cela mais ca fonctionne pas

ROUTER_IP=$1
ROUTER_USERNAME=$2
ROUTER_PASSWORD=$3

# Login
CREDENTIALS=`printf $ROUTER_PASSWORD | sha256sum | head -c64 | base64 -w0`
echo $CREDENTIALS
#CREDENTIALS=`printf "%s%s%s" $ROUTER_USERNAME $CREDENTIALS $TOKEN | sha256sum | head -c64 | base64 -w0`
echo $CREDENTIALS
DATA=`printf "<request><Username>%s</Username><Password>%s</Password><password_type>4</password_type></request>" $ROUTER_USERNAME $CREDENTIALS`
echo $DATA
PostRouterData "/api/user/login" "$DATA"

voici le script complet

#!/bin/sh
# Written by oga83

# Check command line parameters
if [ "$#" -ne 5 ]; then
    printf "Syntax: %s <IP> <Username> <Password> <PhoneNumber> <Message>\n" $0
    exit 0
fi

ROUTER_IP=$1
ROUTER_USERNAME=$2
ROUTER_PASSWORD=$3
SMS_NUMBER=$4
SMS_TEXT=$5
TMP_HEADER_FILE=/tmp/headers.tmp

CURL_OPT=--silent

ProcessRouterResponseHeader()
{
	# Get token from header
	NEWTOKEN=`cat $TMP_HEADER_FILE | grep "__RequestVerificationTokenone: " | awk -F' ' '{print $2}'`
	if [ ! -z "$NEWTOKEN" ]; then TOKEN=$NEWTOKEN; fi
	NEWTOKEN=`cat $TMP_HEADER_FILE | grep "__RequestVerificationToken: " | awk -F' ' '{print $2}'`
	if [ ! -z "$NEWTOKEN" ]; then TOKEN=$NEWTOKEN; fi
	NEWSESSIONID=`cat $TMP_HEADER_FILE | grep "Set-Cookie: SessionID=" | awk -F' ' '{print $2}' | cut -b 1-138`
	if [ ! -z "$NEWSESSIONID" ]; then SESSIONID=$NEWSESSIONID; fi
echo $NEWTOKEN
}

GetRouterData() # Param1: Relative URL
{
	#echo "GET on http://$ROUTER_IP$1"
	RESPONSE=`curl $CURL_OPT --request GET http://$ROUTER_IP$1 \
       		--dump-header $TMP_HEADER_FILE \
        	-H "Cookie: $SESSIONID" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
       		`
	ProcessRouterResponseHeader
}

GetSessionToken() # No parameters
{
	# Get SessionID and RequestVerificationToken
	GetRouterData '/api/webserver/SesTokInfo'
        SESSIONID="SessionID="`echo "$RESPONSE"| grep -oPm1 "(?<=<SesInfo>)[^<]+"`
        TOKEN=`echo "$RESPONSE"| grep -oPm1 "(?<=<TokInfo>)[^<]+"`
}

PostRouterData() # Param1: RelativeUrl, Param2: Data, Param3:bAskNewToken
{
	# Get new token if necessary
	if [ ! -z $3 ]; then
		GetSessionToken
	fi

	#echo "POST on http://$ROUTER_IP$1 :" $2
	RESPONSE=`curl $CURL_OPT --request POST http://$ROUTER_IP$1 \
	       --dump-header $TMP_HEADER_FILE \
	       -H "Cookie: $SESSIONID" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
	       --data "$2"`
	ProcessRouterResponseHeader
}

# Get initial SessionID and RequestVerificationToken
GetSessionToken

# Login
CREDENTIALS=`printf $ROUTER_PASSWORD | sha256sum | head -c64 | base64 -w0`
CREDENTIALS=`printf "%s%s%s" $ROUTER_USERNAME $CREDENTIALS $TOKEN | sha256sum | head -c64 | base64 -w0`
DATA=`printf "<request><Username>%s</Username><Password>%s</Password><password_type>4</password_type></request>" $ROUTER_USERNAME $CREDENTIALS`
PostRouterData "/api/user/login" "$DATA"

# Send SMS
DATA="<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>$SMS_NUMBER</Phone></Phones><Sca></Sca><Content>$SMS_TEXT</Content><Length>${#SMS_TEXT}</Length><Reserved>1</Reserved><Date>`date +'%F %T'`</Date></request>"
PostRouterData "/api/sms/send-sms" "$DATA" 1

# Logout
PostRouterData "/api/user/logout" "<request><Logout>1</Logout></request>"

 

 

Merci d'avance pour votre aide

Partager ce message


Lien à poster
Partager sur d’autres sites

C'est du Shell ton script, ça ne risque pas de fonctionner sur la HC3 !

 

Voici une fonction optimisée pour encoder les couples login:password en base64, qui utilise les spécificités du LUA 5.3 disponible sur la HC3 :

--
-- Encode base64
--
function QuickApp:base64(s)
	-- http://lua-users.org/wiki/BaseSixtyFour
	local bs = { [0] =
		'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
		'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/',
	}
	local byte, rep = string.byte, string.rep
	local pad = 2 - ((#s-1) % 3)
	s = (s..rep('\0', pad)):gsub("...", function(cs)
		local a, b, c = byte(cs, 1, 3)
		return bs[a>>2] .. bs[(a&3)<<4|b>>4] .. bs[(b&15)<<2|c>>6] .. bs[c&63]
	end)
	return s:sub(1, #s-pad) .. rep('=', pad)
end

 

 

Pour le SHA256 je ne sais pas.... je n'ai pas encore eu ce besoin.

 

  • Like 1

Partager ce message


Lien à poster
Partager sur d’autres sites

Oui je sais pour le script c'est pour montrer comment fonctionne la recherche d'encodage du password

 bon en curl je viens d'envoyer mes premiers sms

Alors j'ai utilisé la méthode pour passord type 3 cela fonctionne avec une erreur

merci pour le Base64

MODEM_IP="192.168.8.1"ROUTER_USERNAME="admin"ROUTER_PASSWORD="admin"curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xmlCOOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`# LoginLOGIN_REQ="adminYWRtaW4=3"curl -X POST -d $LOGIN_REQ "http://$MODEM_IP/api/user/login" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" "Content-Type: text/xml" --dump-header login_resp_hdr.txt > /dev/nullgrep "SessionID=" login_resp_hdr.txt | cut -d ':' -f2 | cut -d ';' -f1 > session_id.txtgrep "__RequestVerificationTokenone" login_resp_hdr.txt | cut -d ':' -f2 > token.txtSESSION_ID=`cat session_id.txt`TOKEN=`cat token.txt`echo $TOKENecho "admin session_id\n$SESSION_ID\n"message_data="-10600000000"hello"511" #--compressedcurl -X POST -d $message_data "http://$MODEM_IP/api/sms/send-sms" -H "Cookie: $SESSION_ID" -H "__RequestVerificationToken: $TOKEN"

 

 

 

Partager ce message


Lien à poster
Partager sur d’autres sites

Ca avance plutôt bien

 

via l'api le password et de type 4 donc base64 + SHA256

 

Je sais pas pourquoi mais cela tombe bien j'arrive a me connecté avec un password type 3 juste le mot de passe en base 64

 

Je récupère le cookie (SessionID=xxxxxxxxxxxxxxxxxxxxxxxxxxx)  et le token comme cela

print("/api/webserver/SesTokInfo")
        self.http:request(self.controller .. "api/webserver/SesTokInfo", {
             options = {
                checkCertificate = false,
                method = 'GET',
            },
            success = function(response)
                --print(json.encode(response.data))
                if response.status == 200 then
                   self.cookie = response.data
                   local len = string.len(self.cookie)
                   print(len) --277
                   self.Token = string.sub(self.cookie, 221, 252)--SesInfo
                   self.cookie = string.sub(self.cookie, 62, 199)--TokInfo
                   --self.cookie = string.sub(self.cookie, 72, 199)
                   print("Cookie : ",self.cookie)
                   print("Token : ",self.Token)
                   self:loginUnifi(self.cookie)
                   --self:test(self.cookie)
                end
            end,
            error = function(error)
                self.cookie = nil
                self:error("checkTitreUnifi() échoué: ", json.encode(error))
                self:updateView("Titre", "text", "Controleur UNIFi - checkVersionUnifi() échoué: "..json.encode(error))
            end
        })

pour me connecté avec le mot de passe

local LOGIN_REQ = "<request><Username>admin</Username><Password>YWRtaW4=</Password><password_type>3</password_type></request>"
        self.http:request(self.controller .. "api/user/login", {
            options = {
                checkCertificate = false,
                method = 'POST',
                 headers = {
                    ['Cookie'] = self.cookie ,
                    ["content-type"] = "text/xml", 
                    ['__RequestVerificationToken'] = self.Token
                    },
                data = LOGIN_REQ
            },
            success = function(response)
                print("*********************************************************************************************************************")
                print(response.status)
                print("DATA ---------------------------------------------------------------------------------------------------------------------")
                print(response.data)
                if response.status == 200 then
                   --print("response---------------------------------------------------------------------------------------------------------------")
                   --print (json.encode(response))
                   print("response.headers ------------------------------------------------------------------------------------------------------")
                   for k, v in pairs (response.headers) do
                      print( k.." = "..v )
                   end
                   print("-----------------------------------")
                   print(response.headers['Set-Cookie'])
                   self.NEWCookie = response.headers['Set-Cookie']
                   self.RequestVerificationTokenone = response.headers['__RequestVerificationTokenone']
                   self.RequestVerificationTokentwo = response.headers['__RequestVerificationTokentwo']
                   self.RequestVerificationToken = response.headers['__RequestVerificationToken']
                   print(self.NEWCookie)
                   print(self.RequestVerificationTokenone)
                   print(self.RequestVerificationTokentwo)
                   print (self.RequestVerificationToken)  
                    --self.cookie = response.headers['Set-Cookie']
                    --self:debug("loginUnifi() Connecté")
                    self:updateView("Titre", "text", "Routeur 4G (Connecté)")                    
                end
            end,
            error = function(error)
                self:updateView("Titre", "text", "Controleur UNIFi - loginUnifi() Erreur: "..json.encode(error))
                self:error("loginUnifi() Erreur: ", json.encode(error))
            end
        })

resultat


[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: /api/webserver/SesTokInfo
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: 277
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Cookie : SessionID=7ABN3zTcqPyMUQcdRbY1vxvNhnw5fJLgbr4cLjVlzjeQiMoGDvYIgPHRcoHTfKH2PYgSWi/KVx4u9cbmXzNbzu/jmkcy39zxFFWplmP58kV3cdbgm9mdXnUvqgT0KK2W
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Token : jeZbl+GQq7B/yCWLsNBpss7PPZg/tSRJ
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: *********************************************************************************************************************
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: 200
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: DATA ---------------------------------------------------------------------------------------------------------------------
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: OK
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: response.headers ------------------------------------------------------------------------------------------------------
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Content-Type = text/html
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Server = mini_httpd/1.19 19dec2003
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Cache-Control = no-cache, no-store
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: __RequestVerificationTokentwo = ppvn+Gym61sZi1zHtS2OKqhsrkdtwmuX
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Date = Thu, 01 Jan 1970 00:00:00 GMT
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Pragma = no-cache
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Connection = close
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Set-Cookie = SessionID=kTSE88RERyta8gOU6dTws/t+PMs88QExc3Av2VyF6lz0E/t6kdm2Shzivb7p3WYo1oZMgfHEKNcaXh874t4V7LFC2UpASG8aSg7cAXWxGbvn8QsynJ8z6ZpnH/q+uAMu;path =/;HttpOnly;
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Content-Length = 61
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: X-Frame-Options = deny
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: X-Download-Options = noopen
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: Strict-Transport-Security = max-age=31536000; includeSubdomains
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: X-XSS-Protection = 1; mode=block
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: __RequestVerificationTokenone = f6Gn4H+VFLWH5rKs8GLAx0WPegbJexoy
[06.06.2020] [08:01:32] [DEBUG] [QUICKAPP30]: __RequestVerificationToken = f6Gn4H+VFLWH5rKs8GLAx0WPegbJexoy#ppvn+Gym61sZi1zHtS2OKqhsrkdtwmuX#Sg8LpZVPmNxtVwGOz9zuJBdXgj6VIhGj#/oeu8bb0iW0y4ifyXB9CVpukytGLTMHF#slRpL9Y73aITYreHK2OmXGUlAgvj8PEE#eorIJQcLwc0bdoEIVtlI6doNs+Mxm5qi#p0GvRflZz1nDdfNKAjWi5ziUHCKZjyzG#v3M5a4Ru1lrK9jv4gbFsNexSIAd0kt8m#3cVd+fi/bWfe6Cdt+ffI4AKLWeGtATz5#iaOa4xM7tr9lx55h6yDZco8kqRA6JSih#UjHbwgVjtBeFkSG8bGrnkxsnxx1stef0#4VymZPatzVsILsLxehqJMjmJJT4C8i2z#Nd1UdIGqlAg2mv57L9hpi4s2ASXPV/TG#sUnsfmik7JCuSJzJ7umIRGmcICNKKE4W#pk93h+F7i3UFJaydUIpeucIags75vZED#1Oei3S/dnnTkFl3RoFrO+XoA/TD7/xkY#/tw2KJ6FHIvBog54CGKKRcUGbHA4CH1r#TU7ksjRG/5Yv/CLnuhUr9BWD99KvK8gd#2ZcTOCJNY5P0JgHEsfnEE74c1F4FmQmM#bew3Sj2gKUCOM8rvRbEbEC/bkrXe0vlw#j1rRclNKb2QzAW7jWb8sOaRoKr5yXPCH#U5ntsyW6iGKwonoGwgu6PFIewdnvuU1/#Bfhxtng78qiGJ9HX8lXqaj4IQGWD80sk#6meOxzmGsGdh+9HCw7f3uCYilHucx/sM#CIUdMCTf8R85IiJWLmKIEueu/Bpj625b#63S3dvr6nqnI8P4BVf5+SHWmiQdD0xu8#ckMs1qfSTxLgnM9FBAxkJ+BZ9XBOvZun#Udkw+97IC1DvaMwIa8s7vp0sxV3mRS0r#+sERIEUctQx7Lf9t7QOaZLWgeNdAgK9X#L0RmzlSV/yx9gfbFnNE8Z1T5LaqrtSZi#Cm9NFeAzJvyu5VuvpdtBYPE++gkwKkNH#XXFe4uWR8OWSKQYK/2nwjU0pZY4xxnsV#

si je regarde de plus prêt __RequestVerificationToken

 

f6Gn4H+VFLWH5rKs8GLAx0WPegbJexoy # tokenone
ppvn+Gym61sZi1zHtS2OKqhsrkdtwmuX # tokentwo
Sg8LpZVPmNxtVwGOz9zuJBdXgj6VIhGj #
/oeu8bb0iW0y4ifyXB9CVpukytGLTMHF #
slRpL9Y73aITYreHK2OmXGUlAgvj8PEE #
eorIJQcLwc0bdoEIVtlI6doNs+Mxm5qi #
p0GvRflZz1nDdfNKAjWi5ziUHCKZjyzG #
v3M5a4Ru1lrK9jv4gbFsNexSIAd0kt8m #
3cVd+fi/bWfe6Cdt+ffI4AKLWeGtATz5 #
iaOa4xM7tr9lx55h6yDZco8kqRA6JSih #
UjHbwgVjtBeFkSG8bGrnkxsnxx1stef0 #
4VymZPatzVsILsLxehqJMjmJJT4C8i2z #
Nd1UdIGqlAg2mv57L9hpi4s2ASXPV/TG #
sUnsfmik7JCuSJzJ7umIRGmcICNKKE4W #
pk93h+F7i3UFJaydUIpeucIags75vZED #
1Oei3S/dnnTkFl3RoFrO+XoA/TD7/xkY #
/tw2KJ6FHIvBog54CGKKRcUGbHA4CH1r #
TU7ksjRG/5Yv/CLnuhUr9BWD99KvK8gd #
2ZcTOCJNY5P0JgHEsfnEE74c1F4FmQmM #
bew3Sj2gKUCOM8rvRbEbEC/bkrXe0vlw #
j1rRclNKb2QzAW7jWb8sOaRoKr5yXPCH #
U5ntsyW6iGKwonoGwgu6PFIewdnvuU1/ #
Bfhxtng78qiGJ9HX8lXqaj4IQGWD80sk #
6meOxzmGsGdh+9HCw7f3uCYilHucx/sM #
CIUdMCTf8R85IiJWLmKIEueu/Bpj625b #
63S3dvr6nqnI8P4BVf5+SHWmiQdD0xu8 #
ckMs1qfSTxLgnM9FBAxkJ+BZ9XBOvZun #
Udkw+97IC1DvaMwIa8s7vp0sxV3mRS0r #
+sERIEUctQx7Lf9t7QOaZLWgeNdAgK9X #
L0RmzlSV/yx9gfbFnNE8Z1T5LaqrtSZi #
Cm9NFeAzJvyu5VuvpdtBYPE++gkwKkNH #
XXFe4uWR8OWSKQYK/2nwjU0pZY4xxnsV #

 

Partager ce message


Lien à poster
Partager sur d’autres sites

je viens de comprendre c'est la liste des tokens

les 2 premiers sont extrait response.headers['__RequestVerificationToken']

 

response.headers['__RequestVerificationTokenone']
response.headers['__RequestVerificationTokentwo']
 
 
response.headers['__RequestVerificationToken']
 
f6Gn4H+VFLWH5rKs8GLAx0WPegbJexoy # tokenone
ppvn+Gym61sZi1zHtS2OKqhsrkdtwmuX # tokentwo
Sg8LpZVPmNxtVwGOz9zuJBdXgj6VIhGj #
/oeu8bb0iW0y4ifyXB9CVpukytGLTMHF #
slRpL9Y73aITYreHK2OmXGUlAgvj8PEE #
eorIJQcLwc0bdoEIVtlI6doNs+Mxm5qi #
p0GvRflZz1nDdfNKAjWi5ziUHCKZjyzG #
v3M5a4Ru1lrK9jv4gbFsNexSIAd0kt8m #
3cVd+fi/bWfe6Cdt+ffI4AKLWeGtATz5 #
iaOa4xM7tr9lx55h6yDZco8kqRA6JSih #
UjHbwgVjtBeFkSG8bGrnkxsnxx1stef0 #
4VymZPatzVsILsLxehqJMjmJJT4C8i2z #
Nd1UdIGqlAg2mv57L9hpi4s2ASXPV/TG #
sUnsfmik7JCuSJzJ7umIRGmcICNKKE4W #
pk93h+F7i3UFJaydUIpeucIags75vZED #
1Oei3S/dnnTkFl3RoFrO+XoA/TD7/xkY #
/tw2KJ6FHIvBog54CGKKRcUGbHA4CH1r #
TU7ksjRG/5Yv/CLnuhUr9BWD99KvK8gd #
2ZcTOCJNY5P0JgHEsfnEE74c1F4FmQmM #
bew3Sj2gKUCOM8rvRbEbEC/bkrXe0vlw #
j1rRclNKb2QzAW7jWb8sOaRoKr5yXPCH #
U5ntsyW6iGKwonoGwgu6PFIewdnvuU1/ #
Bfhxtng78qiGJ9HX8lXqaj4IQGWD80sk #
6meOxzmGsGdh+9HCw7f3uCYilHucx/sM #
CIUdMCTf8R85IiJWLmKIEueu/Bpj625b #
63S3dvr6nqnI8P4BVf5+SHWmiQdD0xu8 #
ckMs1qfSTxLgnM9FBAxkJ+BZ9XBOvZun #
Udkw+97IC1DvaMwIa8s7vp0sxV3mRS0r #
+sERIEUctQx7Lf9t7QOaZLWgeNdAgK9X #
L0RmzlSV/yx9gfbFnNE8Z1T5LaqrtSZi #
Cm9NFeAzJvyu5VuvpdtBYPE++gkwKkNH #
XXFe4uWR8OWSKQYK/2nwjU0pZY4xxnsV #
 
 

Partager ce message


Lien à poster
Partager sur d’autres sites

Sous debian c'est bon cela fonctionne a chaque fois

 

j'ai pas mal chercher car je sais pas pourquoi il a fallu mettre un \n a la fin de $TOKEN mais cela fonctionne

MODEM_IP="192.168.8.1"
set echo off
curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml

COOKIE=`grep "SessionID=" ses_tok.xml | cut -b 10-147`
TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
# Login
LOGIN_REQ="<request><Username>admin</Username><Password>YWRtaW4=</Password><password_type>3</password_type></request>"
curl -X POST -d $LOGIN_REQ "http://$MODEM_IP/api/user/login" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" --dump-header login_resp_hdr.txt > /dev/null

grep "SessionID=" login_resp_hdr.txt | cut -d ':' -f2 | cut -d ';' -f1 > session_id.txt
grep "__RequestVerificationTokenone" login_resp_hdr.txt | cut -d ':' -f2 > token.txt

SESSION_ID=`cat session_id.txt`
TOKEN=`cat token.txt`

echo "admin session_id\n$SESSION_ID\n"

message_data='<request><Index>-1</Index><Phones><Phone>0637839778</Phone></Phones><Sca></Sca><Content>bonjour</Content><Length>7</Length><Reserved>1</Reserved><Date>1</Date></request>'
echo $TOKEN
sleep 1
curl -X POST -d $message_data "http://$MODEM_IP/api/sms/send-sms" -H "Cookie: $SESSION_ID" -H "__RequestVerificationToken: $TOKEN\n" -H "Content-Type: text/xml" 

 

Partager ce message


Lien à poster
Partager sur d’autres sites

×