Hello!!

There is an array of bytes, it has the word <IMAGE> , I need to somehow filter this array so that after decoding it is not.

And yes, I had an idea, first to decode this array, find this word in it and delete it, but then I need to encode it back, but after these actions, I had a problem with the encoding, is there a more normal way?
Thanks in advance!

  • (1) What is the encoding of your array? (2) What does “delete” mean? Should the rest of the characters move? Or can it be replaced? - VladD pm
  • I get this array from a file, FileStream("D:/output.jpg",FileMode.Open, FileAccess.Read); Yes, it should, well, that is to remove, so that this line was not - HackMemory
  • Ok, you read an array from a file, say, bytes from 1000 to 1500. Transformed into a string, deleted a substring, converted back, got an array of bytes shorter than the original array. What are you going to do with it next? - VladD
  • Why did you have a problem with the encoding? Have speed requirements? Give an example of a byte array - Alexsandr Ter
  • In general, the essence is, you need to get the file, and send it by socket. I tried to encode in ASCII, then back to normal view. But when I decoded, then there is trouble, the file did not come to me normally. Or, you need to choose the correct encoding, but I do not know how to do it correctly. I tried Unicode, there is not at all that. - HackMemory 5:56 pm

1 answer 1

There is an array of bytes, it has a word, I need to somehow filter this array so that after decoding it is not.

Can be converted to byte array. When you receive a packet, sequentially iterate over the array for a match, it is not necessary to check the entire word every iteration, you can byte-byte for matches. But in this way there is a chance to delete a useful piece of data that has its bytes matched. Even if you decode the entire package as an array of characters and brute force the string, you still have the chance to delete the useful data block.

In general, the essence is, you need to get the file and send it by socket. I tried to encode in ASCII, then back to normal view.

Encode simply into an array of bytes through BinaryWriter, sign with the "leading word" (just a unique set of bytes), record the length of the packet and the packet itself. On that side, read the starting word, then the length of the packet, then the whole packet in length, and unpack the BinaryReador.