Question
Assembly for x86 processors In the following C++ program (encode.cpp which calls into an inline asm code) where an encrypted file is created by the
Assembly for x86 processors
In the following C++ program (encode.cpp which calls into an inline asm code) where an encrypted file is created by the command
encode clear1.txt encoded
Encryption code [0-255]? 0
Reading clear1.txt and creating encoded
Press any key to continue....
The contents of clear1.txt is a text file containing 2 lines of content:
1234
abcd
Under a hex editor it can be seen to have 12 bytes as its this content:
31 32 33 34 0D 0A 61 62 63 64 0D 0A
(0D 0A are the new line characters in windows)
The .cpp file is here:
#include
#include
using namespace std;
void main( int argcount, char *args[] )
{
if( argcount < 3 ) {
count << "Usage: encode infile outfile" << end1; return;
}
const int BUFSIZE = 2000;
char buffer[BUFSIZE];
unsigned int count;
unsigned char encryptCode;
cout << "Encryption code [0-255] ? ";
cin >> encryptCode;
ifstream infile( args[1], ios : : binary );
ofstream outfile( args[2], ios : : binary );
cout << "Reading" << args[1] << " and creating " << args[2] << end1;
while (!infile.eof() )
{
infile.read(buffer, BUFFSIZE );
count = infile.gcount();
___asm {
lea esi, buffer
mov ecx, count
mov al, encryptCode
L1:
xor [esi] , al
inc esi
Loop L1
} // asm
outfile.write (buffer, count) ;
}
}
If 0 (zero) is used as the encryption code (0 is ASII CODE 30H), What does the contents of the file (encoded) look like? Show the contents (12 bytes) of encoded here (in hex):
What command would you run on the command line to decrypt the encoded file? What key must you use?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started