Linux RAW Sockets – Generate VoIP SIP Packets

Hey guys welcome back to another great episode of The Linux Channel in this episode I am going to discuss and going to show you how you can build your custom VoIP SIP Packet and you can do it via C Linux RAW Socket Programming and then I am going to show you a quick code walk like I have done in my previous episode in terms of building your custom OSPF Packet but here is the catch .. you know the SIP Packet is an UDP Packet .. so you need to calculate the checksums for both UDP header as well as the IP header unlike the OSPF packet you can create almost the same way and … I am going to show you the source code and I am going to do a code-walk quick code walk as well as I am going to share the source code in my google drive or my other website and I am going to share the link across the Youtube description from which you can download the source and then I am going to show you also a quick demo of ..

Compiling this code and generating a custom packet so in case you are a network admin or a hacker you can just skip the source code code walk part and you know you can just focus on interms of other aspects interms of building your custom packet and here and there you can do some minimal customization and you can self compile this code and you can just change it according to your need so lets just go to my desktop guys and let me just show my code and let me just show you the quick demo of the same ! Guys .. welcome to my desktop guys 🙂 what I have done is .. I have written this piece of code which is voip_sip I am just going to open it in my IDE (Editor) and do a quick code walk in case you are an admin or in case you are a hacker or something ..

as I discussed earlier you can just skip this part and you can just concentrate on the demo part anyway in case if you are looking for any kind of small customization I hope .. you know .. this code-walk is going to help you I have done earlier an exclusive video on OSPF perhaps you know .. it has almost the similar source-code but it has few elements which are specific to generation of a typical VoIP SIP Packet as such so you have this initial part which has all these typedefs so I am just going to focus on certain elements which are far more important so that you can understand as well as you can customize so what I have done is I have done this large buffer which contains the entire UDP header as well as the SIP pakcet so the initial 8-bytes are going to be the UDP-header so the checksum part what I have done is I left them as 0-bytes as you can see here so this is the entire UDP-header and then followed by which you have this entire SIP packet as such so this is the buffer which is you know primarily going to be used and apart from that there is also another buffer which is a layer-2 header which is the Ethernet header so it has around 14-bytes which you can see here and the type of the Ethernet header is you know 0x08 and 0x00 in hexadecimal so which it means it is going to be an IP-Header followed by which you know it is going to have UDP-Header followed by which it is going to have a SIP-Packet as such so what I have done is I have hardcoded the source address and destination IP-addresses as you can see here in case you want to change it according to your NIC card or something you can just do the modifications accordingly and ..

apart from that .. it is having the code in terms of generating you know check-sum for the UDP header.