Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - Socks5 e VB.NET
Forum - C# / VB.NET - Socks5 e VB.NET

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
GoLDBeRG (Ex-Member)
Expert


Messaggi: 331
Iscritto: 19/12/2005

Segnala al moderatore
Postato alle 8:41
Sabato, 13/06/2009
Questo topic è stato chiuso dal moderatore

ciao raga sto cercando di far connettere con un maledetto socks5 il mio utente ad un server ma riesco a ricevere come risposta dal proxy solo il carattere "€ che non so cosa voglia dire... ditemi se vedete qualcosa che non va....

Codice sorgente - presumibilmente VB.NET

  1. Try
  2.             Randomize()
  3.             Dim num As Integer = Math.Round(arrsocks.Count - 1) * Rnd()
  4.             Dim socksip As String = arrsocks(num)
  5.             Dim pass() As String = Split(socksip, ":")
  6.             socksip = pass(0)
  7.             Dim socksport = pass(1)
  8.             Dim ihe As IPHostEntry = Dns.Resolve("thedivxzone.info")
  9.             s = socksproxy.ConnectToSocks5Proxy("ipsocks", CType(Convert.ToInt32("portasocks"), System.UInt16), ihe.AddressList(0).ToString(), CType(412, System.UInt16), "", "")
  10.             Do While True
  11.                 Dim buffer(1024) As Byte
  12.                 Dim count As Integer = s.Receive(buffer, buffer.Length, SocketFlags.None)
  13.                 If (count <= 1) Then
  14.                     Exit Do
  15.                 End If
  16.                 Try
  17.                     Me.readmessage = (Me.readmessage & Encoding.Default.GetString(buffer, 0, count))
  18.                     If Me.readmessage.EndsWith(New String("|".ToCharArray)) Then
  19.                         Dim args As Object() = New Object() {Me.readmessage}
  20.                         processdata(readmessage)'controllate qui cosa ricevete
  21.                         readmessage = ""
  22.                     End If
  23.                 Catch exception1 As Exception
  24.                 End Try
  25.                 Thread.Sleep(100)
  26.             Loop



CLASSE SOCKSPROXY

Codice sorgente - presumibilmente VB.NET

  1. Imports System
  2. Imports System.Net
  3. Imports System.Net.Sockets
  4. Imports System.Text
  5.  
  6. Public Class socksproxy
  7.  
  8.     Public Shared Function ConnectToSocks5Proxy(ByVal proxyAdress As String, ByVal proxyPort As Short, ByVal destAddress As String, ByVal destPort As Short, ByVal userName As String, ByVal password As String) As Socket
  9.         Dim destIP As IPAddress = Nothing
  10.         Dim proxyIP As IPAddress = Nothing
  11.         Dim request(257) As Byte
  12.         Dim response(257) As Byte
  13.         Dim nIndex As Short
  14.  
  15.         Try
  16.  
  17.             proxyIP = IPAddress.Parse(proxyAdress)
  18.  
  19.         Catch t As FormatException
  20.             proxyIP = Dns.GetHostByAddress(proxyAdress).AddressList(0)
  21.         End Try
  22.  
  23.         Try
  24.             destIP = IPAddress.Parse(destAddress)
  25.         Catch
  26.         End Try
  27.  
  28.         Dim proxyEndPoint As IPEndPoint = New IPEndPoint(proxyIP, proxyPort)
  29.  
  30.         Dim s As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  31.         s.Connect(proxyEndPoint)
  32.  
  33.         nIndex = 0
  34.         request(nIndex + 1) = Hex(5)
  35.         request(nIndex + 2) = Hex(2)
  36.         request(nIndex + 3) = Hex(0)
  37.         request(nIndex + 4) = Hex(2)
  38.         s.Send(request, nIndex, SocketFlags.None)
  39.  
  40.  
  41.         Dim nGot As Integer = s.Receive(response, 2, SocketFlags.None)
  42.         If (nGot <> 2) Then
  43.             Exit Function
  44.         End If
  45.  
  46.         If (response(1) = 255) Then
  47.             s.Close()
  48.         End If
  49.  
  50.         Dim rawBytes() As Byte
  51.  
  52.         nIndex = 0
  53.         request(nIndex + 1) = Hex(5)
  54.         request(nIndex + 2) = Hex(4)
  55.         request(nIndex + 3) = Hex(0)
  56.  
  57.         request(nIndex + 4) = Hex(1)
  58.         rawBytes = destIP.GetAddressBytes()
  59.         rawBytes.CopyTo(request, nIndex)
  60.         nIndex += rawBytes.Length
  61.  
  62.         Dim portBytes() As Byte = BitConverter.GetBytes(destPort)
  63.  
  64.         For i As Integer = portBytes.Length - 1 To 0 Step -1
  65.             nIndex += 1
  66.             request(nIndex) = portBytes(i)
  67.         Next i
  68.  
  69.         s.Send(request, request.Length, SocketFlags.None)
  70.         s.Receive(response)
  71.         If (response(1) <> 0) Then
  72.             Return s
  73.         End If
  74.     End Function
  75. End Class



la classe dovrebbe essere giusta l'ho convertita da una classe in c# funzionante vi posto il link

http://www.codeproject.com/KB/IP/zasocks5proxy.aspx

aiutatemi :pat: :pat:

PM
Avatar
theprogrammer (Normal User)
Guru^2


Messaggi: 2509
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 12:28
Sabato, 13/06/2009
Testo quotato

Postato originariamente da GoLDBeRG:

ciao raga sto cercando di far connettere con un maledetto socks5 ...



Sicuramente questa parte (rispetto all'originale C#)

Codice sorgente - presumibilmente Plain Text

  1. nIndex = 0
  2.         request(nIndex + 1) = Hex(5)
  3.         request(nIndex + 2) = Hex(2)
  4.         request(nIndex + 3) = Hex(0)
  5.         request(nIndex + 4) = Hex(2)



è sbagliata. Dovrebbe essere

Codice sorgente - presumibilmente Plain Text

  1. request(0) = 5
  2.         request(1) = 2
  3.         request(2) = 0
  4.         request(3) = 2
  5.         nIndex = 4



ed e' un errore importante in quanto con

request(nIndex + 1) = Hex(5)

scrivi la versione di SOCKS nell'elemento 1 e non nell'elemento 0

PM
Avatar
GoLDBeRG (Ex-Member)
Expert


Messaggi: 331
Iscritto: 19/12/2005

Segnala al moderatore
Postato alle 13:38
Sabato, 13/06/2009
eh ma nel primo passaggio ce scritto... request(nindex++)=hex(5)
non vuol dire request(nindex+1)=hex(5)????

PM
Avatar
theprogrammer (Normal User)
Guru^2


Messaggi: 2509
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 13:45
Sabato, 13/06/2009
Testo quotato

Postato originariamente da GoLDBeRG:

eh ma nel primo passaggio ce scritto... request(nindex++)=hex(5)
non vuol dire request(nindex+1)=hex(5)????



No

PM
Avatar
GoLDBeRG (Ex-Member)
Expert


Messaggi: 331
Iscritto: 19/12/2005

Segnala al moderatore
Postato alle 15:18
Sabato, 13/06/2009
ho risolto facendo una dll con quella classe in c# e poi implementata in vb... va che è una meraviglia... invece di convertirla è meglio.....

PM
Avatar
theprogrammer (Normal User)
Guru^2


Messaggi: 2509
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 15:59
Sabato, 13/06/2009
Testo quotato

Postato originariamente da GoLDBeRG:

ho risolto facendo una dll con quella classe in c# e poi implementata in vb... va che è una meraviglia... invece di convertirla è meglio.....



Hai fatto bene ... il problema era proprio la conversione (a partire da quello che ti avevo segnalato ...).

PM
Avatar
punkettone90 (Member)
Expert


Messaggi: 279
Iscritto: 16/05/2007

Segnala al moderatore
Postato alle 18:10
Sabato, 13/06/2009
ma... la differenza tra

request(nindex++)=hex(5) e
request(nindex+1)=hex(5)

non è solo che alla fine dell'istruzione nindex è stato incrementato?

PM
Avatar
theprogrammer (Normal User)
Guru^2


Messaggi: 2509
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 19:00
Sabato, 13/06/2009
Testo quotato

Postato originariamente da punkettone90:

ma... la differenza tra

request(nindex++)=hex(5) e
request(nindex+1)=hex(5)

non è solo che alla fine dell'istruzione nindex è stato incrementato?



No

PM
Avatar
Il Totem (Admin)
Guru^2


Messaggi: 3635
Iscritto: 24/01/2006

Segnala al moderatore
Postato alle 15:55
Domenica, 14/06/2009
Se in c# funziona come in C++, lo statement i++ restituisce il valore di i e solo successivamente lo incrementa, mentre ++i incrementa il valore di i e poi lo restituisce.

PM
Pagine: [ 1 2 ] Precedente | Prossimo