hacker


Ingresar con nombre de usuario, contraseña y duración de la sesión
| Portal Hacker | Editorial | Descargas | Ezine |
Inicio Ayuda Ingresar Registrarse
06 de Octubre de 2008, 05:39:29
Noticias: La 1era E-Zine de CPH ya fue liberada, encuentrala
Para ver este enlace Registrate o Inicia Sesion
> aquí

+  Foros pOrtal Hacker
|-+  Programacion
| |-+  Programación en general
| | |-+  Visual Basic (Moderadores: ranefi, crypto136, ziBboh, >> s E t H <<)
| | | |-+  Coding the Easiest and The Best Reverse Connection Ever!!!
0 Usuarios y 1 Visitante están viendo este tema. « anterior próximo »
Páginas: [1] Ir Abajo Imprimir
Autor Tema: Coding the Easiest and The Best Reverse Connection Ever!!!  (Leído 260 veces)
EGzer0
Recien llegado
*
Desconectado Desconectado

Mensajes: 21



Ver Perfil
« : 15 de Diciembre de 2006, 09:59:05 »

hey
i posted this tutorial because i have asked lots of questions...
and i find help only in this forum
thx everybody

this Tutorial teaches you the basics of reverse connecting.

ok this is one of my first VB tutorials. so please if there is any thing needing improvment just tell me. now then the point of reverse connecting is so that the server program can bypass routers or other types of security programs. now in my tutorial i will be using winsock because it is the most used socket tool in VB but you can apply this to any other control you use. all that we have to do is try to connect to an ip, if we fail we can try again. the only thing is if we keep trying over and over we can start wasting system resources so we want our app to pause in between trys. and the last thing is we need to make sure if the connection times out we restart anyway.

so lets start off by adding winsock to our form. then we will add a timer and set the interval to 1000, which is the same as one second. we will have our app then attempt to connet every 10 seconds so after adding your timer lets just double click it and then set up some variables we will use like so:
______________ ______________ ______
Dim PauseTime As Long 'this will be our ten second delay

Private Sub Form_Load()
PauseTime = 10
End Sub
______________ ______________ ______

the next thing we need to do is make it so the timer will run our code every ten seconds.
______________ ______________ ______
Dim PauseTime As Long 'this will be our ten second delay

Private Sub Form_Load()
PauseTime = 10
End Sub

Private Sub Timer1_Timer()
PauseTime = PauseTime - 1
If PauseTime <= 0 Then
PauseTime = 10 'reset the timer

'code here

End If
End Sub
______________ ______________ ______

now then next we will attempt to connect with winsock, and if the connection times out or we get an error then we will just wait another ten secs and try again...
______________ ______________ ______
Dim PauseTime As Long 'this will be our ten second delay

Private Sub Form_Load()
PauseTime = 10
End Sub

Private Sub Timer1_Timer()
PauseTime = PauseTime - 1
If PauseTime <= 0 Then
PauseTime = 10 'reset the timer
Timer1.Enabled = False
Winsock1.Conne ct "127.0.0.1", 776 'this is were we reverse connect to
Dim Chk: Chk = Timer 'our timer to make sure the connection dosent time out
Do While Winsock1.State <> sckConnected Or Winsock1.State <> sckError Or Timer < Chk + 10
DoEvents: Loop 'try to connect and if we get an error move on.
If Winsock1.State <> sckConnected Then Winsock1.Close: DoEvents: Timer1.Enabled = True
End If
End Sub
______________ ______________ ______

so thats your basic code. every 10 seconds it attemptes to connect, and if it cant it waits another ten seconds and trys again. if it does connect the timer stops so it dosent get any more errors. it also needs to handle any errors it gets and be able to detect if its connected, so all we have to do is fill in another little bit of code like so:
______________ ______________ ______
Private Sub Winsock1_Conne ct()
'place code to execute once connected
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
On Error Resume Next: Winsock1.Close: DoEvents 'close the socket
If Timer1.Enabled = False Then Timer1.Enabled = True 'make sure it keeps rying to connect
End Sub
______________ ______________ ______

there you go, thats all you should need to get a good reverse connect type application. plus this code has a small bonus ability. most tutorials ask for two timers, the second one checks if the connection was closed to start trying to reverse connect again, but because of the winsock error code that extra hassle is not needed Smiley. the code could be optimised slightly but in this form it is easy to change the PauseTime settings so that the delay is either longer or shorter depending on your apps needs. also using a timer as to a loop allows you to enable or disable reverse connection quite easily. i hope these examples have helped you.
En línea
Páginas: [1] Ir Arriba Imprimir 
« anterior próximo »
Ir a:  


Ingresar con nombre de usuario, contraseña y duración de la sesión

Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC hacker

Juegos gratis - Articulos PHP - Juegos - Trucos - Letras - Juegos - Juegos Online