I need to send 0xFE (hex value) to a device connected through TCP. I tried following code and observed data on Packet Sender which shows value in ASCII column as 0xFE and hex value as "30 78 66 65". I have tried binascii.hexlify and a lot other strategies but none seem to work as I ain't getting "FE" hex value.  import socket  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('192.168.10.10',59354))  s.sendall(hex(int('FE',16)).encode()) s.close()
36723
I have a long sequence of hex digits in a string, such as      000000000000484240FA063DE5D0B744ADBED63A81FAEA390000C8428640A43D5005BD44   only much longer, several kilobytes.  Is there a builtin way to convert this to a bytes object in python 2.6/3?
56540
I am trying to decode a signal stream coming from a Nevco scoreboard controller:    Packets like this are sent every ~2.7 ms.  I suspect it is some sort of UART signal because it is on the RX line of a ATMEGA48, but I cannot identify the finer protocol details like parity and stop bits. All the combinations I have tried returns junk data, so it may be another encoding scheme.  What's unusual is that the same signal is also sent to the MOSI pin of the microcontroller, but there is no clock signal anywhere.  A .vcd file is .   The shortest pulses (both high and low) are always 8us in length.    This is what two packets look like. Anyone got ideas?
100379
I'm using PuTTY (Windows 7) to send data using a Raw connection. I type in the data I want to send, but I have to press Return to actually have it transmit the data.  However, the problem is that the CR/LF is sent along with the data, which is invalid as far as the server application is concerned.   Is there a way of either having PuTTY not send the actual CR/LF as a result of pressing Return, or another way of sending the data that was just typed in?
12314
Total Crypto Noob here.  I was wondering why in ECDSA the Signing Key is so much (half of) shorter than the Verifying key?  Lets look at some python code:  import ecdsa import binascii signing_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1) verifying_key = signing_key.get_verifying_key() print(binascii.hexlify(signing_key.to_string())  print(binascii.hexlify(verifying_key.to_string())  b'662ab496304f2d99aca32d813dbcba3c3ae10ab2b3359fbe43b05ee40b458cec' b'6632feae645469c16cb31d7e1364cae247bd4322040d7089476614399bcf59b2fccf5060686ab09ee64e1b768ba037184e9a87001a4897a745721f99000b44ee'   lets assume I send verifying keys over the network or store them someware, it would be nice if they were not so long. Is there a way to compress them?  I assume it would be really bad to use the keys vice versa, but I don't understand why.
102835
It's possible to configure a banner for sshd that is to be displayed as a connection is opened, via Banner /etc/motd.ssh in sshd_config.  Note that this is displayed before the authentication occurs, and even when an interactive shell is not launched (e.g. via scp).  If this banner contains characters outside of the printable ASCII range, they seem to be escaped, however.  Is there any way to either disable this escaping, or an alternative way to send textual output back to the client on connection which supports such characters outside of the printable-ASCII range?    This would be useful both for colour escape sequences and Unicode characters.   Related:  (not a duplicate, however, as this question is about another kind of banner, not about color)
70601
I need to monitor the network activities of a process and the bandwidth of the connection. So I decided to use nethog and netperf combine with grep and awk to write the values to a file.   nethog command: nethogs -t  eth0 | grep firefox | awk '{ print $3 }' (I want to take the upload/download speed). The 1st problem is that command doesn't print anything.  More detail: command: nethogs -t  eth0 | grep firefox output:  usr/lib/firefox/firefox-bi�)/4956/1000  0.338867    0.239063 /usr/lib/firefox/firefox-bi�)/4956/1000 0.543555    0.274219 /usr/lib/firefox/firefox-bi�)/4956/1000 0.794531    0.489844 /usr/lib/firefox/firefox-bi�)/4956/1000 0.794531    0.489844 /usr/lib/firefox/firefox-bi�)/4956/1000 0.749023    0.589844 /usr/lib/firefox/firefox-bi�)/4956/1000 1.30098 3.47617 /usr/lib/firefox/firefox-bi�)/4956/1000 1.90449 8.0127 /usr/lib/firefox/firefox-bi�)/4956/1000 5.31641 25.0033 /usr/lib/firefox/firefox-bi�)/4956/1000 8.60762 42.0176   I want the two values at the bottom right. But as you can see the output ain't consistent (the space), add | awk '{print $3}' most of the time return nothing. And I can't fix this.  netperf command: netperf -H 192.168.1.10 and the output is:  Recv   Send    Send                           Socket Socket  Message  Elapsed               Size   Size    Size     Time     Throughput   bytes  bytes   bytes    secs.    10^6bits/sec    524288 524288 262144    10.00    **718.62**   I want to print the value on the bottom right but have no idea how to. That's the 2nd problem => solved by  fedorqui!  Can you guys help me out? Any ideas will be appreciated!
65694
I've got a FileUpload control in an ASP.NET web page which is used to upload a file, the contents of which (in a stream) are processed in the C# code behind and output on the page later, using HtmlEncode.   But, some of this output is becoming mangled, specifically the symbol '£' is output as the Unicode FFFD REPLACEMENT CHARACTER. I've tracked this down to the input file, which is Windows 1252 ('ANSI') encoded.   The question is,   How do I determine whether the file is encoded as 1252 or UTF8? It could be either, and How do I convert it to UTF8 if it is in Windows 1252, preserving the symbol £ etc?   I've looked online but cannot find a satisfactory answer.
14562
I found a program which takes a purely alphabetical message, converts the letters to their ASCII values and combines them with the ASCII values of an alphabetical key (wrapping around when it gets to Z).  (The key being used is fully random and is required to be at least a long as the message.)  But from what I usually read about one-time pads, the message and the key are in binary, and the bits in the message is XORed with the key to produce the ciphertext. Combining the ASCII values sounds like a similar but obviously very different process.  Is this a valid way to implement a one-time pad? Or does the process merely resemble the binary XOR and doesn't have the same cryptographic properties as a one-time pad?
271
How do you left pad an int with zeros when converting to a String in java?  I'm basically looking to pad out integers up to 9999 with leading zeros (e.g. 1 = 0001).
114381
Some systems, that operate over flaky bearers, need to send signed, encrypted messages that are entirely self contained - i.e. send a single 300 byte UDP rather than have a 10Kb, two-way, certificate conversation over TCP.  Assume the destination has a private key and already knows the source's public key, and the source has a private key and already knows the destination's public key.  Given this assumption, is there a standard for encrypting/signing a small, but arbitrary length, message?  (I'm well aware of the dangers of rolling my own encryption scheme.)  Would there be a minimum ciphertext size that is related to the public key size?  (I'm thinking plain PKI encryption for plaintexts shorter than the key, and a PKI encrypted AES key for longer plaintexts.)
2031
How can you convert a byte array to a hexadecimal string, and vice versa?
101058
Looking at the  entry on Wikipedia, I can't figure out how it's indicated how long the Ethernet frame is.  The EtherType/Length header field apparently can indicate either a frame type or an explicit length, and I'm guessing that in the case of a frame type, it has to do some other logic to figure out how long the packet is.  For example, if the EtherType field is 0x0800, that indicates an IPv4 payload, and so the receiving NIC would have to examine the first 32 bits of the payload to find the length of the IP packet, and therefore to figure out the total length of the Ethernet frame, and know when to look for the end-of-frame checksum and interframe gap.  Does this sound correct?  I also looked at the  for Ethernet (part 1, anyway) which seems to corroborate this, but it's pretty opaque.
90867
I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?  For example:  I get back:  &amp;#x01ce;   which represents an "ǎ" with a tone mark.  In binary, this is represented as the 16 bit 01ce.  I want to convert the html entity into the value  u'\u01ce'
9867
I am running Wireshark on my linux machine and i have simple python web server running on localhost:8080  I am capturing only local port 8080. When i open browser on localhost:8080 wireshark captures huge amount of tcp communication (as page loads with all resources) but there`s no HTTP only TCP...   Why i cannot capture HTTP on custom port ?
76414
Background: This question relates to versions of Delphi below 2009 (ie without Unicode support built in). I have a specification that requires me to transmit a Unicode encoded string over a TCP connection but I do not have Delphi 2009.   Question Is there a single function or very small library (I don't need too much bulk) that I can use to encode a single string into UTF-8 immediately prior sending over the wire? As a second part of my question: if there are UTF-8 encoded strings being sent back as a response, I guess I would then need another function to get it back into a Delphi string format. I understand the limitations of such Unicode support in this way.
38473
I just want ask how the socket in the image is called?   I couldn't really find and the closer I could get is only Raspberry's module.
78880
Ok, I realize this situation is somewhat unusual, but I need to establish a TCP connection (the 3-way handshake) using only raw sockets (in C, in linux) -- i.e. I need to construct the IP headers and TCP headers myself.  I'm writing a server (so I have to first respond to the incoming SYN packet), and for whatever reason I can't seem to get it right.  Yes, I realize that a SOCK_STREAM will handle this for me, but for reasons I don't want to go into that isn't an option.  The tutorials I've found online on using raw sockets all describe how to build a SYN flooder, but this is somewhat easier than actually establishing a TCP connection, since you don't have to construct a response based on the original packet.  I've gotten the SYN flooder examples working, and I can read the incoming SYN packet just fine from the raw socket, but I'm still having trouble creating a valid SYN/ACK response to an incoming SYN from the client.  So, does anyone know a good tutorial on using raw sockets that goes beyond creating a SYN flooder, or does anyone have some code that could do this (using SOCK_RAW, and not SOCK_STREAM)?  I would be very grateful.    MarkR is absolutely right -- the problem is that the kernel is sending reset packets in response to the initial packet because it thinks the port is closed.  The kernel is beating me to the response and the connection dies.  I was using tcpdump to monitor the connection already -- I should have been more observant and noticed that there were TWO replies one of which was a reset that was screwing things up, as well as the response my program created. D'OH!  The solution that seems to work best is to use an iptables rule, as suggested by MarkR, to block the outbound packets.  However, there's an easier way to do it than using the mark option, as suggested.  I just match whether the reset TCP flag is set.  During the course of a normal connection this is unlikely to be needed, and it doesn't really matter to my application if I block all outbound reset packets from the port being used.  This effectively blocks the kernel's unwanted response, but not my own packets.  If the port my program is listening on is 9999 then the iptables rule looks like this:  iptables -t filter -I OUTPUT -p tcp --sport 9999 --tcp-flags RST RST -j DROP