Liam Prange | 13 Nov 13:58 2007
Picon

Trouble Creating File

Hi all,

I am new to assembly language and I am having trouble
writing a program that creates a file.  The file does
get created, however, the program always causes a
segmentation fault.  The program is called "test" and
you give the name of the file you wish to create as an
argument, like so:  ./test create.txt

..section .data
..section .bss
..lcomm BUFFER, 500
..section .text
..globl _start
_start:

  movl %esp, %ebp  #setup for referencing the stack

  #Open/Create the file we are writing to
  movl $5, %eax
  movl 8( %ebp ), %ebx
  movl $03101, %ecx
  movl $0666, %edx
  int $0x80
  movl ( %eax ), %ebx    #save the fd

  #close the file
  movl $6, %eax
  int $0x80

(Continue reading)

LaPoint, Adam W | 13 Nov 17:33 2007

RE: Trouble Creating File

Change
  movl ( %eax ), %ebx    #save the fd
to
  movl %eax, %ebx

-----Original Message-----
From: linux-assembly-owner <at> vger.kernel.org
[mailto:linux-assembly-owner <at> vger.kernel.org]On Behalf Of Liam Prange
Sent: Tuesday, November 13, 2007 7:58 AM
To: linux-assembly <at> vger.kernel.org
Subject: Trouble Creating File

Hi all,

I am new to assembly language and I am having trouble
writing a program that creates a file.  The file does
get created, however, the program always causes a
segmentation fault.  The program is called "test" and
you give the name of the file you wish to create as an
argument, like so:  ./test create.txt

..section .data
..section .bss
..lcomm BUFFER, 500
..section .text
..globl _start
_start:

  movl %esp, %ebp  #setup for referencing the stack

(Continue reading)

ninjaboy | 13 Nov 19:17 2007
Picon

Re: Trouble Creating File

2007/11/13, LaPoint, Adam W <Adam.W.LaPoint <at> usa-spaceops.com>:
> Change
>   movl ( %eax ), %ebx    #save the fd
> to
>   movl %eax, %ebx
>
>
> -----Original Message-----
> From: linux-assembly-owner <at> vger.kernel.org
> [mailto:linux-assembly-owner <at> vger.kernel.org]On Behalf Of Liam Prange
> Sent: Tuesday, November 13, 2007 7:58 AM
> To: linux-assembly <at> vger.kernel.org
> Subject: Trouble Creating File
>
>
> Hi all,
>
> I am new to assembly language and I am having trouble
> writing a program that creates a file.  The file does
> get created, however, the program always causes a
> segmentation fault.  The program is called "test" and
> you give the name of the file you wish to create as an
> argument, like so:  ./test create.txt
>
> ..section .data
> ..section .bss
> ..lcomm BUFFER, 500
> ..section .text
> ..globl _start
> _start:
(Continue reading)

Liam | 15 Nov 06:01 2007
Picon

Help finding ARGC

Hi all,

I was reading about ARGC and that it holds how many
arguments were given on the command line when the
program was executed.

My question is, where is it on the stack?

If I do:

movl %esp, %ebp

at the beginning of the program, how can I get to the
ARGC value?

      ____________________________________________________________________________________
Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.  http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Mike Osipov | 15 Nov 10:56 2007
Picon

Re: Help finding ARGC

in the beginning of execution %esp point to argc value
get it: movl (%esp), %eax
or: popl %eax
Now %eax contains argc value
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

SCURTU VITALIE | 16 Nov 09:14 2007
Picon

(unknown)

Hello everyone. 
I am working on an open source project, called opensourcemep (on sf). 
I am trying to develope a cross-platform class in C++, combined with optimized 
assembler code . 
Everything went well, until I descovered that the directives for including 
assembler code are different across C++ compilers.
Does anyone know how to solve this problem? 
What combination should I choose for having a cross-platform source code? 
Best Regards,
Vitalie Scurtu

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

copyandpaste | 23 Nov 17:04 2007
Picon
Picon

Stacklayout GCC 4.1.2. - EBP differs?

Hello,
I currently read a book about buffer overflows and format string vulns.
During my readings in the book I found something that I dont understand. 

I have the following code:

--

-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

copyandpaste | 23 Nov 17:19 2007
Picon
Picon

Stacklayout GCC 4.1.2. - EBP differs?

Hello,

sorry for the spam. 
Again... read a book about buffer overflows and format string vulns.
In my attachment is the vulnerable code. 
I compiled it with gcc -g -o stack_bof stack_bof.c and ran it with gdb 6.7.1.
In gdb I made a breakpoint at the end of the function 'funktion' (line 11) and ran it with the input of 11 times
'A'. 

When the program interrupts at the breakpoint, I examined the stack frame of the function by doing 
(gdb) x/6x buff2 
which gave the following result:
0xbfa39a08:0x00434241   0x41414141  0x41414141   0x00414141
0xbfa39a18:0xbfa39a38   0x0804843d

So the stack contains the "ABC" from buff2 and all the 11 "A"s from buff1.
After that comes the saved frame pointer from main() and the RIP from main().
So here the register EBP was 0xbfa39a38.

_But_ if let gdb show me the frames by typing 

(gdb) bt
#0  funktion (args=0xbfa3b247 'A' <repeats 11 times>) at stack_bof.c:11
#1  0x0804843d in main (argc=2, argv=0xbfa39ad4) at stack_bof.c:19
and 
(gdb) info frame 0
Stack frame at 0xbfa39a20:
 eip = 0x8048400 in funktion (stack_bof.c:11); saved eip 0x804843d
 called by frame at 0xbfa39a40
 source language c.
(Continue reading)

Steffen Solyga | 27 Nov 22:12 2007
Picon

Re: Help finding ARGC

maybe you want to have a look at this one
http://linux.xulin.de/asm/cmdline/

Citing Mike Osipov (Thursday, 2007/11/15 12:56)...

> in the beginning of execution %esp point to argc value
> get it: movl (%esp), %eax
> or: popl %eax
> Now %eax contains argc value
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--

-- 
------------------------------------
Steffen Solyga
mail: solyga <at> absinth.net
www : http://www.absinth.net/solyga/
------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane