I am creating and sending an SNMP packet manually using pcap.net, the reason for this is that I need to be able to change the sender details of the SNMP packet to one other than the application hosts NIC and which wouldn't be possible with the library unless I somehow intercepted the outgoing packet and changed the details on the fly. My issue is that I can send out my packet and receive it using pcap.net as well but I need a way to decode the BER encoded packet, can I directly decode a received packet without using the rest of the library? If so what function could I call so I can read the oid values directly from a recieved packet?
When you first asked this question I read it but could not provide much insight.
What #SNMP offers are the two set of functions below,
MessageFactory.ParseMessage, a few functions that parse raw bytes to ISnmpMessage.
ISnmpMessage.ToBytes, a method that generates raw bytes.
If you can write adapters to bridge #SNMP and Pcap.NET, you should be able to achieve what you want.
Next time, make sure you avoid C# tag, as yes you might be down voted due to that.
References:
http://help.sharpsnmp.com/html/Overload_Lextm_SharpSnmpLib_Messaging_MessageFactory_ParseMessages.htm
http://help.sharpsnmp.com/html/M_Lextm_SharpSnmpLib_Messaging_ISnmpMessage_ToBytes.htm
Related
Is there a way to log or view the actual bytestream being sent to the server when using either the grpc or #grpc/grpc-js clients in NodeJS?
I'm working with an opaque GRPC server that accepts my bytes when I stream them, but doesn't do what it's supposed to do. I'd like to view the actual bytes being sent to the server, as we suspect it's a problem with how the GRPC libraries are serializing 64 bit integers.
The GRPC_VERBOSITY=debug GRPC_TRACE=tcp,http,api,http2_stream_state env variables for the native grpc module haven't been helpful in this specific case -- they show part of one byte stream, but not the full byte-stream.
Even a "here's the place in the code where the serialization happens" would be useful.
The GRPC_VERBOSITY setting there is correct. If you are using TLS, you can see all of the data that is sent and received with GRPC_TRACE=secure_endpoint. If you are using plaintext connections, you can instead see it with GRPC_TRACE=tcp. In both cases, you will need to pick the data you are looking for out of the HTTP/2 framing, and it may show compressed messages, which would be essentially impossible to interpret.
Alternatively, if your setup allows it, you may want to try Wireshark. It should be able to handle the HTTP/2 framing for you, and I believe it has plugins to handle gRPC traffic specifically.
I'm writing a application in NodeJs where a client sends udp messages to a server with udp. I'm trying to find out how people normally handle different message types in NodeJs but can only find tons of examples of echo servers where the kind of message is not relevant.
The only example I have found so far is https://github.com/vbo/node-webkit-mp-game-template/tree/networking_1/networking
Maybe the best way is to send the udp messages as json?
User Datagram Protocol (UDP) is a network protocol and mechanism for sending short messages from one host to another without any guarantee of delivery. What you put in the message is entirely up to you.
While JSON can be used to encode your message, it suffers from two problems: it is not secure and is self-describing.
The first problem means that bad actors can easily see the content of your message while in flight and the second implies a substantial overhead for any message above and beyond its intended purpose.
Depending on your needs, a better choice might be to define your own binary protocol specific to your purpose using a node Buffer.
Another might be to use a more compact interchange format like thrift.
I am creating a GUI with PyQT4 on Python 3. I however am trying to setup a serial port using PySerial that I can later implement into this GUI. I don't know how to view if the command being sent is what I want so is there a program I can use to see the correct bytes are being sent?
To be more clear: I want to see the BYTES being sent or received.
Use pyserial's read and write methods to check what you're receiving from the peripheral and what you're sending to it. You could optionally use the method to_bytes to dig deeper, even though most serial devices accept only ASCII commands.
Also, the Serial class has builtin logging, you only need to enable it.
It doesn't relate specifically to any programming language or technique, but still:
You know how you can use programs like Wireshark to read packets going through your computer (or router, more accurately)? These packets can contain secret information that must be encrypted somehow, like username and password for some systems. But even without this information, one can recreate these packets and obtain the same information, no? For example, I can send these packets from my computer, pretend that I've requested the service and obtain access that way to the given system. How is that prevented?
Also, a kind-of-related question: when a router receives a packet, how does it know to which computer to direct it to if multiple computers are connected to it in an LAN?
What you describe is called a replay-attack - to prevent this sort of attack the respective protocol needs to have some built-in features (like some unique ID per request and becomes invalid after being received the very first time and/or becomes invalid after a certain amount of time and/or some timestamp etc.).
hai..
how to generate raw pockets and send to another system using winpcap in vc++.i had done capture packets(sniffer) using winpcap in vc++
kindly help me
Thanks
You can send packets using WinPcap, it's part of its interface (the basic function is called pcap_sendpacket).
In order to generate packets, you can simply write the packets' bytes.
What type of packets do you want to send? I have some experience creating packets, but I did that in C# (If you want to do that in .NET, you can create and send packets easily using Pcap.Net).