• Welcome to Valhalla Legends Archive.
 

Sending/Recieving Packets

Started by dodge, May 18, 2004, 08:16 AM

Previous topic - Next topic

dodge

I was windering if anyone knew of a site that throughly explained how to send/recieve packets. Or maybe someone could give me an example? I searched google and I still am but I can't find anything besides forums you have to sign up tio see a responce.  :-\

Grok

Quote from: dodge on May 18, 2004, 08:16 AM
I was windering if anyone knew of a site that throughly explained how to send/recieve packets. Or maybe someone could give me an example? I searched google and I still am but I can't find anything besides forums you have to sign up tio see a responce.  :-\

You did not specify a language or platform.  We need to know whether you are using Windows, Linux, Solaris, and then the programming language.

iago

#2
Since he didn't specify a platform, I'm going to have to assume he's using Java:

void testfunc() throws Exception
{
 Socket s = new Socket(INetAddress.getAddrFromName("http://www.google.ca"));
 s.getOutputStream().write("GET / http/1.1\nHost:www.google.ca\n\n".getBytes());

 while(true)
    System.out.print((char) s.getInputStream().read();
}
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


dodge

whoops sorry, I'm using VB. In the long run a bnet bot but im not there yet.

Eric

#4
Send:
Winsock.SendData
Receive:
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Winsock.GetData
End Sub

Grok

Quote from: LoRd[nK] on May 18, 2004, 12:10 PM
Send:
Winsock.SendData
Receive:
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Winsock.GetData
End Sub


Neither of those work.

iago

#6
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately.  I forget how to do it, but I suspect it's under the Project menu, under components maybe?  Something like ctrl-t?  My brain hurts :/

Also, giving those functions parameters would help too.

And I guess that means I typed that Java code for nothing.  Oh well :)

[moves this topic to VB forum]
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Eric

Quote from: iago on May 18, 2004, 12:40 PM
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately.  I forget how to do it, but I suspect it's under the Project menu, under components maybe?  Something like ctrl-t?  My brain hurts :/
I'm the teacher's assistant, not the teacher.  Perhaps he should find a Visual Basic tutorial or even buy a book. :p

Grok

#8
Quote from: LoRd[nK] on May 18, 2004, 01:10 PM
Quote from: iago on May 18, 2004, 12:40 PM
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately.  I forget how to do it, but I suspect it's under the Project menu, under components maybe?  Something like ctrl-t?  My brain hurts :/
I'm the teacher's assistant, not the teacher.  Perhaps he should find a Visual Basic tutorial or even buy a book. :p

His question was either to explain how, or to give an example.  Since you're unwilling to do either, you should have passed this thread by.  Lately everyone on these forums thinks they are being cool by demonstrating how much they refuse to help someone who needs or wants help.

Eli_1

#9
Forgive me for my typos :P


'/**************************************
'******Step 1: Adding The Control*******
'**************************************/

'// To create a project that uses the
'// winsock control, the first thing
'// you need to do is add the activeX
'// component to your project.

'// First click on 'Project' at
'// the top.

'// Go down to the bottom and click on
'// 'Components... Ctrl+T'
'// (It's the one right above 'Project properties...'
'// on mine).

'// A 'Components' window will popup.
'// Scroll down this list of components untill
'// you find the Winsock Control.
'// Microsoft Winsock Control 6.0 (SP5) on mine.
'// Simply check the box next to it and click 'Ok'





'/***************************************
'*****Step 2: Putting it on The Form*****
'***************************************/

'// Simply click on the winsock control on
'// the left hand side, where all the other
'// things you commonly use are -- Textbox, Label, ect...

'// The winsock control is the one with the little
'// network icon (the two little computers -- one being blue,
'// the other being green).






'/***************************************
'*******Step 3: Adding The Events********
'***************************************/

'// The easiest way to do this is to go into
'// the code window (View -> Code).

'// Once there, select what your winsock control is
'// named in the combobox (Winsock1 for this example)
'// at the top. And select the event you want to add
'// directly to the right of the name.






'/**************************************
'******Step 4: An Event Overview********
'**************************************/

'// I'll explain this one by example because
'// it's the easiest way I can think of.


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)
   '// This event is self-explanitory.
   
   '// This event will be called with the error
   '// number along with a description of what happened.
   
   '// Note: This event is raised when your ipbanned,
   '// for example.
End Sub

Private Sub Winsock1_SendComplete()
   '// This event will be raised when SendData returns.
   '// This one isn't really that important.
End Sub

Private Sub Winsock1_SendProgress( _
ByVal bytesSent As Long, _
ByVal bytesRemaining As Long)
   '// This will tell you the current progress
   '// of SendData.
   
   '// I've never used this... =/
End Sub

Private Sub Winsock1_Close()
   '// This event is raised when your connection
   '// is terminated.
End Sub

Private Sub Winsock1_Connect()
   '// Contrary to what most beginners like to think,
   '// this event is raised when your [i]CONNECTED[/i].
   
   '// Example: If you were writing a bnet bot
   '// using the CHAT protocol, you would
   '// put your login stuff here.
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
   '// This event is raised when someone is
   '// requesting to connect.
   
   '// If you made a chat server in VB,
   '// this event would be raised every time
   '// a new user trys to connect to you.
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
   '// Self-explanitory
   
   '// When you receive data, this event will be raised.
   
   '// Example:
   Dim Data As String
   Winsock1.GetData Data
End Sub





'/***************************************
'*****Final Step: How To Send Data*******
'***************************************/

'// Since SendData wasn't discussed in the
'// above examples, I'll put it here.

'// Note: Sending data while not connected
'// will cause an error... duh... :P

Private Function MySendData(ByVal Data As String) As Integer
   '// This function will attempt to send
   '// 'Data' to whatever server you're connected
   '// to.
   
   '// If no connection is currently
   '// established, the function will return
   '// -1 for error.
   
   '// If the send is successful, the function
   '// will return a 0.
   
   Const SOCKET_CONNECTED As Integer = 7
   If Winsock1.State <> SOCKET_CONNECTED Then
       '// The socket isn't connected to anything.
       MySendData = -1 '// Failure
   Else
       Winsock1.SendData Data
       MySendData = 0 '// Success
   End If
   
End Function
   
'// Useage:
'// Dim RetVal as Integer
'// RetVal = MySendData("Hello, world!" & vbCrLf)




'// With Love:
'//     Eli_1

Soul Taker

I might as well be the first to ask: why do you put the VB comments inside of C-like comments?

Eli_1

#11
Quote from: Soul Taker on May 18, 2004, 07:01 PM
I might as well be the first to ask: why do you put the VB comments inside of C-like comments?
Because I've found that C-style comments seem to stand out much more as a comment than the simple single-quote VB uses. It's just much much easier for me to read when it's like that.

Edit: I'll remove them if you want though, I'm not the one that needs to read this. So if the C-style comments there make it harder/confusing for you to read, say the word and I'll repost it.

Eric

#12
Quote from: Grok on May 18, 2004, 01:29 PM
Quote from: LoRd[nK] on May 18, 2004, 01:10 PM
Quote from: iago on May 18, 2004, 12:40 PM
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately.  I forget how to do it, but I suspect it's under the Project menu, under components maybe?  Something like ctrl-t?  My brain hurts :/
I'm the teacher's assistant, not the teacher.  Perhaps he should find a Visual Basic tutorial or even buy a book. :p

His question was either to explain how, or to give an example.  Since you're unwilling to do either, you should have passed this thread by.  Lately everyone on these forums thinks they are being cool by demonstrating how much they refuse to help someone who needs or wants help.
It's not as if every Winsock control function isn't covered in Visual Basic's Object Browser and help files.

Also, by using the small amount of information I provided, you could do an easy google search and be provided with endless amounts of information that are most likely more descriptive and indepth than most people on this forum, including myself, could write.

In most cases, a gentle shove in the right direction is much better in the long run than just handing out code that won't be understood.

dodge

#13
Wow I checked this before I left and suddenly I checked it at school and 1000 people responded. For more information, I do know how to add the Winsock control, and View Code. But people are talking about "sending 0x65" and I have no idea what they mean "sending" I was working a chat thing between computers for my class incase we "couldn't talk" but then I realized it wasn't really worth it. Hope this helps a little bit... but thanks for the feedback everyone lol.

Edit:

I'm confused but here's a little guess on sending "0x65"


Winsock1.SendData 0x65


Edit:

I found this in a forum... yeah I need to fine a site explaining this, guess an example won't help lol.


Public Sub 0x3A()
    Dim dblseen as long, PacketData as string
    dblseed = Val("&h" StrToHex(StrReverse(Token)))
    PacketData = string(7 * 4, vbNullChar)
    Result = a(PacketData, CLng(dblseed), varCDkey)
    Packet.insertNonNTString PacketData
    Packet.InsertNTString varUser
    Packet.SendPacket &H3A
End Sub

*Note: I added spaces so, you know, people that have a big problem with coding being all vertically lined up (me)

iago

Nobody has said anything about sending 0x65 besides you.  

His instructions in that code are fairly clear - try following them.  I think I've seen a chat client like you're describing on pscode.com before, but it might have been C++ (I forget).
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*