Sign in to follow this  
Followers 0
Decipher

Torrent Info Hash Encoding

21 posts in this topic

#1 ·  Posted (edited)

I would like to programmatically check to see if a given tracker has information on the torrent I specify. This requires that the SHA-1 Info Hash of a torrent be encoded to make valid requests. I read from: http://nakkaya.com/2009/12/03/bittorrent-tracker-protocol/ If you don't pay attention to the spec and send this directly to tracker you will get an error this should be in URL Encoded form. Padding every two chars with % sign also doesn't work, been there done that don't waste your time. Any hex in the hash that corresponds to a unreserved character should be replaced,

a-z A-Z 0-9 -_.~

Partition the hex in to chunks of two and check if the hex corresponds to any of these values, if they do replace them with the unreserved char.

So that a hash such as,

123456789abcdef123456789abcdef123456789a

becomes,

%124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9a

notice that hex 34 became 4 which is what it is in ASCII. You can test the correctness of your hashes using the tracker url but don't request from announce request from file,

http://some.tracker.com/file?info_hash=hash

If you get a torrent back that means you have the correct hash.

I have tried the above and failed. Here's my code:

$testStr = "123456789abcdef123456789abcdef123456789a"
ConsoleWrite(_EncodeHash($testStr) & @CRLF)
Func _EncodeHash($sString)
    If (Not IsString($sString)) Or $sString = "" Then Return SetError(1, 0, 0)
    Local $aArray = StringRegExp($sString, "(?s).{1," & 2 & "}", 3), $sEncodedHash
For $i = 0 To UBound($aArray) -1
    If StringInStr($sString, Chr(Dec($aArray[$i]))) Then
     $sEncodedHash &= Chr(Dec($aArray[$i]))
    Else
     $sEncodedHash &= "%" & $aArray[$i]
    EndIf
    Next
Return $sEncodedHash
EndFunc

If you follow the first link in my post there is an example but I'm unfamiliar with the language being used. Thanks for any help.

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm actually stuck on this. ;) I'd appreciate any help or general suggestions that appropriately pertain to this topic.

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Hey JohnOne, you're absolutely correct. I consider myself to be an important individual. I would usually have something negative to say but I'm being humble. I'll wait until after I've made six thousand posts and never decide to suggest not bumping threads unless the OP feels important. Thanks for your first suggestion. I can't wait to endure number two but I'd rather stay on topic. ;)


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Decipher,

This is forum etiquette. Plus the support you get is from people who want to help not have to help, so learn how to be patient.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I understand that you bumped the thread repeating what was already said by JohnOne and that neither of you would like to help but instead litter. ;)


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Thanks I solved the problem at hand.

$Topic = 1

$Reponse = 0

$Help = 0

Dim $Bump

If $Topic = 1 And $Reponse = 0 Then

$Bump = 1

EndIf

If $Bump >= 1 Then $Unnecessary_Posts = Random(2, 10)

Exit


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

I just took this from the spec:

Note that all binary data in the URL (particularly info_hash and peer_id) must be properly escaped. This means any byte not in the set 0-9, a-z, A-Z, '.', '-', '_' and '~', must be encoded using the "%nn" format, where nn is the hexadecimal value of the byte. (See RFC1738 for details.)

For a 20-byte hash of x12x34x56x78x9axbcxdexf1x23x45x67x89xabxcdxefx12x34x56x78x9a,

The right encoded form is %124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A

I think I realize what I'm doing wrong....... I'm still waiting for help guies and no, I'm not trying to bump this thread it is relevant information.


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Decipher,

I do not like the tone you have taken so far in this thread - please alter it in future. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Yes ma'am, I have solved my problem by myself. Heres the code:

#include <array.au3>
$INFOHASH = "123456789abcdef123456789abcdef123456789a"
ConsoleWrite(_EncodeHash($INFOHASH) & @CRLF)
Func _EncodeHash($sString)
    If (Not IsString($sString)) Or $sString = "" Then Return SetError(1, 0, 0)
    Local $aArray = StringRegExp($sString, "(?s).{1," & 2 & "}", 3), $sEncodedHash
For $i = 0 To UBound($aArray) -1
    If StringInStr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_~", Chr(Dec($aArray[$i]))) Then
     $sEncodedHash &= Chr(Dec($aArray[$i]))
    Else
     $sEncodedHash &= "%" & $aArray[$i]
    EndIf
    Next
Return $sEncodedHash
EndFunc
;%124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9a
;%124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9a

Would you mind telling exactly how long I shall wait in the future before bumping, if it is even allowed.

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Decipher,

I am a "Sir", thank you! ;)

Like most public forums we prefer you not to bump your own thread within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. Or if not - tough! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I will from now on. ;)


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

I think you should wait atleast a day before bumping.

Some people have a thing called "A life", you've probably heard of it, and therefore can't be online all the time.

Post, wait, and if nothing, bump after 24 hours.


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I think you should wait atleast a day before bumping.

Some people have a thing called "A life", you've probably heard of it, and therefore can't be online all the time.

Post, wait, and if nothing, bump after 24 hours.

@Maffe811,

Seriously, You have to bored out of your mind taking the time out of your precious life to say what has been said once than again by a mod.

Sorry Melba32 I had to tell this poor guy.

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Well, not really, i was reading the topic and was quite entertained by your behaviour and i took my time even finding some snacks.

So when i finally got arround to post a reply, some had beaten me to it.

But from the post you made answearing JohnOne i was just waiting for you to step over the line and get thrown out.

You should read the forum rules, they mention:

Do not be obnoxious, rude or in general a nuisance to the smooth operation of the forum.


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Similar Content

    • Danyfirex
      By Danyfirex
      Hello guys. Here is a small function to create a hash hmac  similar to hash_hmac PHP function.  
      Supported are: SHA512,SHA256,SHA1,SHA384,MD5 and RIPEMD160.
       
      Local $sSecret = "SecretKey" Local $sMessage = "AutoIt Rocks!!!" ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA512", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA256", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA1: " & @TAB & @TAB & _HashHMAC("SHA1", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA384: " & @TAB & @TAB & _HashHMAC("SHA384", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-MD5: " & @TAB & @TAB & _HashHMAC("MD5", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-RIPEMD160: " & @TAB & _HashHMAC("RIPEMD160", $sMessage, $sSecret) & @CRLF) Func _HashHMAC($sAlgorithm, $bData, $bKey, $bRaw_Output = False) Local $oHashHMACErrorHandler = ObjEvent("AutoIt.Error", "_HashHMACErrorHandler") Local $oHMAC = ObjCreate("System.Security.Cryptography.HMAC" & $sAlgorithm) If @error Then SetError(1, 0, "") $oHMAC.key = Binary($bKey) Local $bHash = $oHMAC.ComputeHash_2(Binary($bData)) Return SetError(0, 0, $bRaw_Output ? $bHash : StringLower(StringMid($bHash, 3))) EndFunc ;==>_HashHMAC Func _HashHMACErrorHandler($oError) ;Dummy Error Handler EndFunc ;==>_HashHMACErrorHandler It requires .NET Framework  2.0 or higher.
      Saludos
    • wakillon
      By wakillon
      HttpHeaderWatcher v1.0.1.3
       

      Some time ago, some members asked how to see the Http Requests.
      There are quite a few external applications but not in AutoIt!
      HttpHeaderWatcher in association with WinPcap, very modestly solves this lack.
       
      Once done this http watcher, i asked me : why not Re-build a WinHttp Request in AutoIt from a selected Request in one Click ?
      So i have added a "Create au3" button who open the WinHttp Request of your choice in AutoIt format in SciTE Editor.
      Voila voila, hope it can help ! 
      Buttons were made online with chimply.com the easy and free buttons generator !
      See Help for more infos.
      previous downloads : 253
      source and executable are available in the Download Section
      Hope you like it !
    • X_xkijux_x
      By X_xkijux_x
      Ok so im using this program. clarify for school. I would like to have a program that takes every word i type in microsoft word and searches on it in claryfi. is this possible. I would like to have the program not stopping me from typing more after that word. Like when i type a word it auto search it on clarify without making me stop typing and if i want to change i can do that and if im fine that word i can just keep typing and it will search after the next word. 
    • Miliardsto
      By Miliardsto
      Is this possible to make program works like in diagram? There is so much encryption methods and UDFs are they give security? If the $Address will be crypted with some encryption algorithm could be possible to get the value of $Address in easy way? Of course We know its easy too look into autoit code and get value of variable and so We dont want to anyone see $Address value - there are functions Could func1.au3, func2.au3.. be for example func1.php or other type of file? As we know .php files are unnable to see. For example func1 would be read by FileRead() and then Execute() Is this generally possible to do?
      Will it give secure?
      What do you think about? Maybe there is something wrong in this concept or missed.

    • JaredStroeb
      By JaredStroeb
      I need to open an application and send it keys in Session 0.  I have exe's working locally, I can see the application open in session 0 through interactive services, but my send commands do not go to the application.  The following article running-autoit-session-0, directs me to use ControlSend() however my application has no controls that can be identified by AutoIt v3 Window Info.  Get All Windows Controls also returned nothing for the application's handle.  
      What are my options?  
      Can this be done with AutoIt?
      Is there a different "relatively simple" library/tool to use? (I am familiar with C# if there is a viable library there )