[R] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

[R] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#1

Message par Boulanza »

Bonjour,
Je cherche un script Autoit pour obtenir des informations sur les domaines à partir des serveurs WhoIs. http://whois.domaintools.com/Votre Nom de domaine
J’ai cherché sur tous les forums un code qui marche pour obtenir des informations sur les domaines mais hélas ça ne fonctionnent pas.
Merci pour votre aide.
Cordialement.
Modifié en dernier par Boulanza le sam. 11 mai 2019 00:02, modifié 2 fois.
Avatar du membre
jchd
AutoIt MVPs (MVP)
AutoIt MVPs (MVP)
Messages : 2272
Enregistré le : lun. 30 mars 2009 22:57
Localisation : Sud-Ouest de la France (43.622788,-1.260864)
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#2

Message par jchd »

Il suffit de traiter la page renvoyée par http://whois.domaintools.com/autoitscript.com par exemple.
La cryptographie d'aujourd'hui c'est le taquin plus l'électricité.
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#3

Message par Boulanza »

Ramadan karim...
Merci jchd pour votre réponse et votre suggestion.
Comment je peux traiter la page renvoyée par http://whois.domaintools.com/autoitscript.com. Je n'ai aucune notion à ce sujet, un lien ou un exemple me suffira.
Cordialement.
Avatar du membre
orax
Modérateur
Modérateur
Messages : 1479
Enregistré le : lun. 23 mars 2009 04:50
Localisation : ::1
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#4

Message par orax »

Une autre solution serait d'utiliser l'outil en ligne de commande Whois de Sysinternals. Il peut être téléchargé sur https://docs.microsoft.com/fr-fr/sysint ... oads/whois
De petits détails peuvent faire toute la différence. — Quand la boule de neige commence à rouler… poussez-la. (Columbo)
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#5

Message par Boulanza »

Merci orax pour votre réponse, ce que je cherche à récupérer les données d'une page Web, j'ai testé votre proposition ça répond pas à mes besoins.
Je continue de chercher une solution comme proposée par jchd.
A+
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#6

Message par Boulanza »

Bonjour,
Ce code réalisé par mikell copie la page web dans le fichier code.ini. Y a-t'-il moyen de supprimer toutes les lignes du fichier ini ou de la page Web pour ne laisser que les lignes suivantes avec leurs informations:
Registrant Name:
Registrant Organization:
Registrant Street:
Registrant City:
Registrant State/Province:
Registrant Postal Code:
Registrant Country:
Registrant Phone:
Registrant Phone Ext:
Registrant Fax:
Registrant Fax Ext:
Registrant Email:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "https://www.whois.com/whois/autoitscript.com ", 0)
$oHTTP.Send()
$txt = $oHTTP.Responsetext
$oHTTP = 0
$txt2 = StringRegExpReplace($txt, '\h|(<br />)', "")
;Msgbox(0,"", $txt2)
 FileWrite("code.ini", $txt2)
ShellExecute(@ScriptDir&"\code.ini")
Cordialement
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#7

Message par mikell »

C'est basique. Vous lisez la page avec la méthode habituelle, BinaryToString(InetRead(...)) etc
Et vous faites ceci

$res = StringRegExp($page, '(?m)^Registrant\N+', 3)
_ArrayDisplay($res)
Mais c'est aléatoire, le format de la page étant susceptible d'être différent suivant le domaine recherché. L'outil évoqué par orax me parait nettement plus fiable
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#8

Message par Boulanza »

Bonjour,
Le code suivant répond à ma demande mais il reste à modifier le résultat obtenu comme expliqué ci-dessous :

Le résultat obtenu:
930:RegistrantName:REDACTEDFORPRIVACY
931:RegistrantOrganization:AutoItConsultingLtd
932:RegistrantStreet:REDACTEDFORPRIVACY
933:RegistrantCity:REDACTEDFORPRIVACY
934:RegistrantState/Province:ABE
935:RegistrantPostalCode:REDACTEDFORPRIVACY
936:RegistrantCountry:GB
937:RegistrantPhone:REDACTEDFORPRIVACY

Le résultat que je cherche: Supprimer les numéros de 930 à 937,: et le mot "Registrant" puis séparer les mot des phrases comme ci-dessous

Name: REDACTED FOR PRIVACY
Organization: AutoIt Consulting Ltd
Street: REDACTED FOR PRIVACY
City: REDACTED FOR PRIVACY
State/Province: ABE
PostalCode: REDACTED FOR PRIVACY
Country: GB
Phone : REDACTED FOR PRIVACY

Je vous avoue que j'ai aucune notion pour arriver au résultat recherché. Votre aide SVP.
Cordialement.
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "https://www.whois.com/whois/autoitscript.com", 0)
$oHTTP.Send()
$txt = $oHTTP.Responsetext
$oHTTP = 0
$txt2 = StringRegExpReplace($txt, '\h|(<br />)', "")
;Msgbox(0,"", $txt2)
 FileWrite("code.ini", $txt2)
;=============
Global $file = @ScriptDir & "\code.ini", $search = "RegistryRegistrantID"
Global $iLine = 0, $sLine = '', $iValid = 0
Global $hFile = FileOpen($file)
If $hFile = -1 Then
    MsgBox(0,'ERROR','Unable to open file for reading.')
    Exit 1
EndIf

; find the line that has the search string
While 1
    $iLine += 1
    $sLine = FileReadLine($hFile)
    If @error = -1 Then ExitLoop

    ; test the line for the $search string until the flag $iValid is set
    If StringInStr($sLine, $search) And Not $iValid Then
        $iValid = 1
        ContinueLoop
    EndIf

    If $iValid Then
        $iValid += 1
        ConsoleWrite($iLine & ':' & $sLine & @CRLF)
     ;   Msgbox(0,"", $sLine)
      FileWrite("Résultat.ini", $iLine & ':' & $sLine & @CRLF)
      If $iValid > 8 Then ExitLoop
    EndIf
WEnd
FileClose($hFile)
Sleep(100)
FileDelete(@ScriptDir & "\code.ini")
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#9

Message par Boulanza »

Bonjour à tous,
je souhaiterais supprimer un mot "Registrant" et tout ce qui se trouve à gauche"chiffres aléatoire": de ce mot qui se trouve dans un fichier texte , tout les mots sont à la ligne .
StringReplace($STR, "numéro de la ligne aléatoires :Registrant", " ")
Merci pour votre aide.
Cordialement.
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [..] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#10

Message par Boulanza »

Le code finale à optimiser:
;=====================================
FileDelete(@ScriptDir & "\code.ini")
 Sleep(100)

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "https://www.whois.com/whois/autoitscript.com", 0)
$oHTTP.Send()
$txt = $oHTTP.Responsetext
$oHTTP = 0
$txt2 = StringRegExpReplace($txt, '', "")
;Msgbox(0,"", $txt2)
 FileWrite("code.ini", $txt2)
;~ Exit
;=============
Global $file = @ScriptDir & "\code.ini", $search = "Registry Registrant ID:"
Global $iLine = 0, $sLine = '', $iValid = 0
Global $hFile = FileOpen($file)
If $hFile = -1 Then
    MsgBox(0,'ERROR','Unable to open file for reading.')
    Exit 1
EndIf

; find the line that has the search string
While 1
    $iLine += 1
    $sLine = FileReadLine($hFile)
    If @error = -1 Then ExitLoop

    ; test the line for the $search string until the flag $iValid is set
    If StringInStr($sLine, $search) And Not $iValid Then
        $iValid = 1
        ContinueLoop
    EndIf

    If $iValid Then
        $iValid += 1
        ;ConsoleWrite($iLine & ':' & $sLine & @CRLF)
      ; Msgbox(0,"", $sLine)
FileWrite("Résultat.ini", $iLine & ':' & $sLine & @CRLF)
If $iValid > 10 Then ExitLoop
EndIf

WEnd
FileClose($hFile)
Sleep(100)
FileDelete(@ScriptDir & "\code.ini")
 Sleep(100)
;Exit

Local $file1 = @ScriptDir & "\Résultat.ini"
Local $inp = FileRead($file1)
Local $out = StringRegExpReplace($inp, '', '')
;~ ;MsgBox(0, "", $out)

            $STR = $out
            $STR = StringReplace($STR, "925:Registrant", " ")
         $STR = StringReplace($STR, "926:Registrant", " ")
         $STR = StringReplace($STR, "927:Registrant", " ")
         $STR = StringReplace($STR, "928:Registrant", " ")
         $STR = StringReplace($STR, "929:Registrant", " ")
         $STR = StringReplace($STR, "930:Registrant", " ")
         $STR = StringReplace($STR, "931:Registrant", " ")
         $STR = StringReplace($STR, "932:Registrant", " ")
         $STR = StringReplace($STR, "933:Registrant", " ")
         $STR = StringReplace($STR, "934:Registrant", " ")
         $STR = StringReplace($STR, "935:Registrant", " ")
         $STR = StringReplace($STR, "936:Registrant", " ")
         $STR = StringReplace($STR, "937:Registrant", " ")
         $STR = StringReplace($STR, "938:Registrant", " ")
         $STR = StringReplace($STR, "939:Registrant", " ")
         $STR = StringReplace($STR, "940:Registrant", " ")
;MsgBox(0, "", $STR)
;Exit
;============================================
;~ Local $file1 = @ScriptDir & "\Résultat.ini"
;~ Local $inp = FileRead($file1)
;~ Local $out = StringRegExpReplace($inp, '', '')

;~ $regex1 =   "(?i)([1-9]+)\s*(:)\h*(Registrant)"     ;"(?i)([1-9]+)\s*(:)\h*"    ;"(?i)([a-z]+)\s*(:)\h*(.*)"    ;"(?i).+Registrant:.*\v?" Registrant
;~          $txt1 = $out
;~          $txt1 = StringRegExpReplace($txt1, $regex1, "")
;~          msgbox(0,"2",$txt1)
;~          GUICtrlSetData($out, $txt1)
;~ Exit
;===========================================
;MsgBox(0, "", $STR)
;MsgBox(0, "Resultat", "Avant : "&$out&@CRLF&"Après : "&$STR)
 FileWrite("Code.ini", $STR );$STR   ;$txt1
FileDelete(@ScriptDir & "\Résultat.ini")
 Sleep(100)

Exit
Boulanza
Niveau 9
Niveau 9
Messages : 697
Enregistré le : mer. 31 juil. 2013 15:49
Status : Hors ligne

Re: [R] Je cherche un script pour obtenir des informations sur les domaines à partir des serveurs WhoIs

#11

Message par Boulanza »

Bonjour,
Je viens de remarquer que Domain Name: il n'est pas dans la liste pourquoi ?
Comment ajouter "id="registrarData">Domain Name: autoitscript.com" parmi les éléments de recherche:
Global $file = @ScriptDir & "\code.ini", $search = "Registry Registrant ID: " pour avoir dans la liste: Domain Name: autoitscript.com

Une autre question: Pourquoi "whois_email" lors de la recherche nous donne comme repense ceci:
Registrant Email: 941:Registrant Email: <img src="/eimg/a/39/a3913c68f50559edd6e81cdf143cbbffca4b51d8.png" class="whois_email" alt="email">@1und1.de
Comment faire pour avoir l'email complète : Registrant Email: email@1und1.de ?

Merci d'avance pour votre aide
Cordialement.
Répondre