Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 9th, 2006, 12:31 AM   #1
backstabber
Newbie
 
Join Date: Oct 2006
Posts: 9
Rep Power: 0 backstabber is on a distinguished road
Question read access violation

this program is compiled using mingw and borland c++ and it gives a read access violation error (olly debug) when it starts the search for "the"

#include <cstdlib>
#include <iostream>
#include "file.h"
#include "alpha.h"

using namespace std;

int main(int argc, char *argv[])
{
    char fileout[302];
    char key;
    int iter =0;
    for (int w = 0; w < 102; w++)
    {
        key = alpha[w];
    for (int i = 0; i < 302; i++)
    {
        fileout[i] = key ^ file[i];
        }
    for (int f = 0; f < 302; f++)
        {
             iter++;
             if (fileout[iter] == 0x74 && fileout[iter+1] == 0x68 && fileout[iter+2] == 0x65)
             {
                            for (int d = 0; d < 302; d++)
                            {
                                cout << fileout[d];
                            }
             }
        }
}
}
it a little messy but this app pulls a single char from the alpha[] array and xors it with ever char in the file array this is a challenge please only fix the access violation not any thing else and a few hints as to good code production would help
this is an xor brute forcer
backstabber is offline   Reply With Quote
Old Oct 9th, 2006, 12:50 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Too little information. There's no indication as to what "alpha" or "file" is. If you're looking for psychic phenomena, I suggest you check the midway at your nearest state fair. Violations of this type are often caused by attempting to access memory which isn't yours to access, or by attempting to write to memory which is only readable. A very common cause is presuming that some pointer can contain the information which you seek, when it can only contain information directing you to the information which you seek. If that information is not separately provided, or if you have not informed the pointer of the proper location of said information, you are up the proverbial creek. Paddling upstream in wave-ridden dung with a needle is not recommended.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 9th, 2006, 1:44 AM   #3
backstabber
Newbie
 
Join Date: Oct 2006
Posts: 9
Rep Power: 0 backstabber is on a distinguished road
sorry heres the extra info

alpha.h
const char alpha[102] = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,0x57, 0x58, 0x59, 0x5A, 0xFC, 0xF6, 0xE4, 0xDC, 0xD6, 0xC4, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,0x36, 0x37, 0x38, 0x39, 0x3D, 0x21, 0x22, 0xA7, 0x24, 0x25, 0x26, 0x2F, 0x28, 0x29, 0x7B, 0x5B,0x5D, 0x7D, 0x3F, 0x5C, 0x2D, 0x2B, 0x2A, 0x5F, 0x2C, 0x2E, 0x3B, 0x3A, 0x23, 0x27, 0x7E, 0x3C,0x3E, 0x7C, 0x40, 0x5E, 0xB0, 0x20};

file.h

const char file[302] = {0x2F, 0x0A, 0x1E, 0x07, 0x45, 0x1D, 0x17, 0x01, 0x17, 0x47, 0x45, 0x00, 0x17, 0x1A, 0x55, 0x1D, 0x00, 0x59, 0x1B, 0x1D, 0x13, 0x08, 0x0E, 0x1C, 0x1C, 0x4F, 0x13, 0x05, 0x0A, 0x0D, 0x10, 0x0A, 0x00, 0x4B, 0x00, 0x17, 0x1B, 0x1D, 0x0B, 0x1B, 0x11, 0x10, 0x17, 0x01, 0x52, 0x08, 0x0A, 0x1D, 0x1D, 0x41, 0x7F, 0x61, 0x2C, 0x1F, 0x58, 0x16, 0x1D, 0x1E, 0x45, 0x11, 0x19, 0x19, 0x17, 0x05, 0x42, 0x0D, 0x58, 0x0E, 0x1E, 0x19, 0x00, 0x18, 0x1C, 0x16, 0x52, 0x05, 0x0A, 0x0D, 0x11, 0x0C, 0x17, 0x0F, 0x45, 0x0D, 0x10, 0x06, 0x01, 0x4B, 0x0A, 0x17, 0x1D, 0x4F, 0x05, 0x0A, 0x16, 0x59, 0x00, 0x00, 0x00, 0x4B, 0x00, 0x17, 0x1B, 0x1D, 0x0B, 0x1B, 0x11, 0x10, 0x17, 0x01, 0x5E, 0x4B, 0x04, 0x17, 0x1C, 0x4F, 0x06, 0x03, 0x00, 0x59, 0x1B, 0x07, 0x13, 0x05, 0x06, 0x1C, 0x0B, 0x4F, 0x13, 0x19, 0x00, 0x59, 0x01, 0x00, 0x07, 0x4B, 0x10, 0x0A, 0x1D, 0x4F, 0x01, 0x04, 0x08, 0x1C, 0x58, 0x0C, 0x1A, 0x0E, 0x04, 0x09, 0x58, 0x0E, 0x00, 0x18, 0x00, 0x59, 0x10, 0x0E, 0x0A, 0x04, 0x17, 0x59, 0x0C, 0x00, 0x1D, 0x07, 0x45, 0x0D, 0x17, 0x4F, 0x10, 0x19, 0x00, 0x18, 0x13, 0x4F, 0x1B, 0x1F, 0x49, 0x59, 0x0C, 0x07, 0x17, 0x4B, 0x0B, 0x1C, 0x00, 0x1B, 0x52, 0x04, 0x0B, 0x1C, 0x58, 0x18, 0x1D, 0x05, 0x11, 0x59, 0x1A, 0x0A, 0x52, 0x18, 0x0A, 0x59, 0x1D, 0x0E, 0x01, 0x12, 0x4B, 0x74, 0x72, 0x3B, 0x1A, 0x0E, 0x45, 0x1A, 0x17, 0x0B, 0x17, 0x4B, 0x1C, 0x16, 0x0D, 0x4F, 0x1C, 0x0E, 0x00, 0x1D, 0x58, 0x09, 0x1D, 0x19, 0x45, 0x00, 0x17, 0x1A, 0x00, 0x4B, 0x0B, 0x1C, 0x00, 0x1B, 0x52, 0x18, 0x11, 0x18, 0x0A, 0x4F, 0x1B, 0x18, 0x45, 0x5E, 0x0A, 0x00, 0x0A, 0x0E, 0x09, 0x09, 0x15, 0x06, 0x01, 0x4C, 0x45, 0x0A, 0x17, 0x4F, 0x17, 0x05, 0x11, 0x1C, 0x0A, 0x4F, 0x06, 0x03, 0x0C, 0x0A, 0x58, 0x06, 0x1C, 0x4B, 0x11, 0x11, 0x1D, 0x4F, 0x13, 0x1B, 0x15, 0x0B, 0x17, 0x1F, 0x00, 0x02, 0x04, 0x0D, 0x1D, 0x4F, 0x02, 0x07, 0x04, 0x1A, 0x1D, 0x41};
backstabber is offline   Reply With Quote
Old Oct 9th, 2006, 1:49 AM   #4
backstabber
Newbie
 
Join Date: Oct 2006
Posts: 9
Rep Power: 0 backstabber is on a distinguished road
the file.h is making the page slow it has about half a meg of info in it
backstabber is offline   Reply With Quote
Old Oct 9th, 2006, 2:06 AM   #5
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Next time, make sure your tabs are right.

Here's your problem:
for (int f = 0; f < 302; f++)
        {
             iter++;
             if (fileout[iter] == 0x74 && fileout[iter+1] == 0x68 && fileout[iter+2] == 0x65)
             {

Firstly, what is the goal of iter++, while you already have f?
Now, your actual error: When f equal 301, iter will contain the same value. You can figure out yourself what the answer of 301 + 2 is.
Polyphemus_ is offline   Reply With Quote
Old Oct 9th, 2006, 2:13 AM   #6
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
Not to mention that iter is incremented inside the inner loop, but is never reset in the outer loop, so it could get up to about 30,000 if the program didn't crash.
The Dark is offline   Reply With Quote
Old Oct 11th, 2006, 3:29 AM   #7
backstabber
Newbie
 
Join Date: Oct 2006
Posts: 9
Rep Power: 0 backstabber is on a distinguished road
nope that did not fix the "READ ACCESS VIOLATION"
backstabber is offline   Reply With Quote
Old Oct 11th, 2006, 3:35 AM   #8
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
You need to show your changed code. I made the changes suggested by Polyphemus_ and I didn't get an access violation. I didn't get any output either, but maybe thats what you were expecting.
The Dark is offline   Reply With Quote
Old Oct 11th, 2006, 11:47 PM   #9
backstabber
Newbie
 
Join Date: Oct 2006
Posts: 9
Rep Power: 0 backstabber is on a distinguished road
there is a read access violation at the point of entry of the first iteration when it starts the check for the word "the" when it tries to pull up the array it crashes would you like the complete dissasembly to help you understand what i am trying to get help with, now that i know its not my source code thats the problem maybe some other program is moving the array.

this is the error i get from olly when i put it through

read access violation at address ???????? and when i go to the point where the program crashes it is the FIRST iteration the FIRST occurence of the loop
backstabber is offline   Reply With Quote
Old Oct 11th, 2006, 11:56 PM   #10
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
How do you know it is not your code? You really need to post your changes.
Does this happen with the short file.h (that you posted) or the 1/2 MB one that you mentioned.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to private files. Jhaqen Java 2 Nov 2nd, 2005 2:35 PM
How to connect with VB to an Access database on another computer iown714 Visual Basic 5 Aug 4th, 2005 10:23 AM
Read Programm Version from outside lgiordano C 4 Jul 13th, 2005 9:58 AM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM
Access Violation Error cornish_boy84 Delphi 1 Mar 1st, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC