root cannot write to Linux RAM


 
Thread Tools Search this Thread
Special Forums Cybersecurity root cannot write to Linux RAM
# 1  
Old 12-21-2011
root cannot write to Linux RAM

Code:
void main() {

long ((long)(&array));
int x;
for (;;)
{
(array) =+ 1023;
printf("%c", array[0]);

}


}

What is wrong with this code to print Linux RAM?
# 2  
Old 12-21-2011
That looks like some weird sort of function pointer, not an array. I'm not sure what you're even trying to do.

Even when running as root, your program gets run in user space, with its own private, virtual memory layout. You literally don't have any memory except pages the kernel has given you, every memory access is checked in hardware. Stray outside that range and your process dies with SEGV like any other.
# 3  
Old 12-21-2011
My errors;

Quote:
[xander@localhost ~]$ gcc overflow.c -o over
overflow.c: In function ‘main’:
overflow.c:3:8: error: expected identifier or ‘(’ before ‘long’
overflow.c:3:13: error: expected ‘)’ before ‘(’ token
overflow.c:7:2: error: ‘array’ undeclared (first use in this function)
overflow.c:7:2: note: each undeclared identifier is reported only once for each function it appears in
overflow.c:8:1: warning: incompatible implicit declaration of built-in function ‘printf’
# 4  
Old 12-21-2011
Okay. Nothing to do with root then, since your program didn't even compile.

What are you trying to do? I can't show you how to do that until you explain what you actually want.
# 5  
Old 12-21-2011
The Linux kernel is in RAM. I want write access to that location.

---------- Post updated at 06:24 PM ---------- Previous update was at 06:21 PM ----------

I'm using a Samsung with VIA processor. 64x. Fedora x64 14.00

Any ideas?
# 6  
Old 12-21-2011
You agreed not to bump posts when you registered. If we don't answer instantly, wait!

Your program isn't running in real mode. You can't access physical addresses just by plugging in the right pointer.

The kernel keeps a list of what memory belongs to your process, and what address your process uses them at. It could give you physical memory address 0x0000000 but make it appear in your process at 0x80000000. And using any virtual addresses that haven't been assigned just causes SEGV. This is all handled in hardware by your processor.

If you want to access physical addresses in Linux, you have to actually ask for them. There's special device files you can read from to get it. /dev/kmem will be the kernel memory area and nothing but the kernel memory area. /dev/mem, I think, is raw RAM contents -- not that useful since the real pages could be scrambled in any virtual order inside the processes themselves. There's also things like memory holes for I/O to consider.

Code:
char buf[16384];
int fd=open("/dev/kmem", O_RDONLY);
read(fd, buf, 16384); // first 16KB of kernel mem

# 7  
Old 12-21-2011
Quote:

#g`�=��=��=� ��=� ��=��=`��=�^��=����=@V��/K�`�=�Z�� @��[����`�=���=XV����[���e`�=��`�=^��=XV��zx`�=�^��=0�[��.�`�=@V��`��8�[��L���9�%v�����Y�N�ł4[�;Nx��N��1 @���=Z3�����=�y`�=x�[��=
0�[����[����[��@ELF>p���=@��@8
@QP@@��=@��=0����=���=��=��=� � ��=��=�G�� @K@K��=@K��=�pp��=p��=DD��=��=�P�td����=���=�e�eQ�td��[��p�[����[��^��=XV���`�=�`�=x��= �[��0�[��?�[��м`�=��[��Ɗ`�=&����[����[��@�[��P[�����|o�`�=&��[��P0<��=��[��h<��=�����`�=��p�[��!�`�=����= ^��XV��t`�=��= `�= �[��0�[�����=��[��0�[������= ^�����|��`�= ^��=����=���{���= �[��@�[��t`�=Ɗ`�=��[����[��Uu�0�[����=U�q��`�=���=XV��?Ɗ`�=X�_���[�� `�=��[��P[��.N=�o�`�=��=8��.�p:��=�[��h<��=h���=�
`�=�
��=p�[����[�����=�[��XV��<@��=���=Xo�����=��[���[�����=�[��.N=���`�=�[�������=`��=���=��[����[����_��<@���[����[���@@h���=@0��=�@p@��[������
@]���=��[��T@��Q�Zwip@��[�����$|�������
i��@��[��p@��[���@��[��/�[��6�[��I�[��]�[��|�[����[����[����[����[����[��K�[��Y�[��t�[����[���[���[��m�[����[����[����[����[����[��$�[��r�[����[����[���[���[��)�[��:�[��M�[��Z�[��{�[����[����[����[����[����[���[���[��$�[��3�[����[����[���[��!�[��:�[��G�[����[����[����[��!�_����ɯd@@8p@

����[����[����[��Âq��k)רI��4�`x86_64./overSSH_AGENT_PID=1699KDE_MULTIHEAD=falseHOSTNAME=localhost.localdomainDM_CONTROL=/var/run/xdmctlGPG_AGENT_INFO=/tmp/gpg-TqMd6L/S.gpg-agent:1730:1SHELL=/bin/bashTERM=xtermXDG_MENU_PREFIX=kde4-XDG_SESSION_COOKIE=2e5de1aa11bfcac29b258b4a00000022-1324481055.741821-1095202158HISTSIZE=1000XDM_MANAGED=method=classicGTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/xander/.gtkrc-2.0:/home/xander/.gtkrc-2.0-kde4:/home/xander/.kde/share/config/gtkrc-2.0KONSOLE_DBUS_SERVICE=:1.181GS_LIB=GTK_RC_FILES=/etc/gtk/gtkrc:/home/xander/.gtkrc::/home/xander/.kde/share/config/gtkrcWINDOWID=144704597SHELL_SESSION_ID=357bbe76d005400098579e13da1bea69KDE_FULL_SESSION=trueUSER=xa nderLS_COLORS=rs=0:di=01;34:ln=01;36:mh=00Smiliei=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01Smilier=40; 31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42Smiliew=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tg z=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01; 31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=0 1;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31: *.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bm p=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=0 1;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01; 35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:* .nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv =01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35 :*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*. mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=0 1;36:*.xspf=01;36:
Update: The above code produced this output. With a lil few changes.

This is really strange. Where is the kernel?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Need assistance to enable more that 4GB RAM on Linux 32Bit OS.

How to enable more than 4GB RAM support on Linux 32bit OS? OS: CentOS release 5.4 (Final) Kernel version: 2.6.18-53.el5 Arch: 32Bit I got solution at Innovationframes.com &bull; View topic - How to enable more than 4GB RAM support on Linux 32bit OS? but my question is the steps given... (5 Replies)
Discussion started by: chandranjoy
5 Replies

2. Linux Benchmarks

AMD Phenom(tm) 9950 Quad-Core Processor, Ram: 3.6 GB, Foxconn 7da-s and Linux 2.6.26-2-amd64

CPU/Speed: AMD Phenom(tm) 9950 Quad-Core Processor Ram: 3.6 GB Motherboard: Foxconn 7da-s Bus: Cache: Controller: Disk: Load: Kernel: Linux 2.6.26-2-amd64 Kernel ELF?: pgms: ============================================================== BYTE UNIX Benchmarks (Version... (0 Replies)
Discussion started by: migracho
0 Replies

3. Red Hat

red hat Linux 5.0 is detecting 3gb ram but physical ram is 16gb

Hi, On server 64bit Hw Arch , Linux 5.0(32bit) is installed it is showing only 3gb of ram though physical is 16gb can u give me idea why? (4 Replies)
Discussion started by: manoj.solaris
4 Replies

4. Linux

Installation of Linux in 300 MHz with 128 MB ram

Hi I am very new to Linux, but very keen to learn it. I am having a desktop of 300 MHz with 128 MB RAM and 30 GB hard drive with Windows XP. My first question is - Is there any version/flavour of Linux available that can be installed on above system especially Fedora with less compromise... (6 Replies)
Discussion started by: sanjay1979
6 Replies

5. Shell Programming and Scripting

To find the RAM size for an Linux server.

Hi Gurus, Can someone let me know how to find the RAM size,ROM size and Number of processors for a linux server. Version :Linux 2.4.9-e.57smp Also what does "e.57smp" stands for? Thanks in advance gurus..... cheers. (3 Replies)
Discussion started by: navojit dutta
3 Replies

6. UNIX for Dummies Questions & Answers

Linux for Pentium @ 150 Mhz and 98Mb in RAM?

I don't know a lot of the world of Linux, but i want to start with an old machine; did someone knows if i can install Linux in a computer with a processor Pentium (not celeron) @ 133 Mhz, 98Mb in RAM (PC100) and 3Gb Hard Drive? a friend tell me about Ubuntu and openSUSE, but I don't know if... (5 Replies)
Discussion started by: Omega
5 Replies

7. Debian

what is the best linux ver for p100 16 ram

Hello all i own p100 16ram laptop , i would like to run linux on it i need it for gcc compilation and shell scripting , no gui. what version of linux should i install , i dont mind to install old one . tnx allot (5 Replies)
Discussion started by: umen
5 Replies

8. UNIX for Dummies Questions & Answers

How do i access (mount, read & write) a floppy disk from the console, not being root?

welll, the title quite explains what i want to do thanks for your time! (4 Replies)
Discussion started by: kfaday
4 Replies

9. UNIX for Dummies Questions & Answers

How much RAM does RH Linux need?

I wish to install Red Hat linux 7.1 on a machine with 16mb of EDO Ram. When I enter the instalation process I am told 'You do not have enough memory'. Is there a way to install RHL with only the 16? Or will I have to upgrade and buy some very expensive EDO. ~ Paul (3 Replies)
Discussion started by: KrazyGuyPaul
3 Replies

10. UNIX for Dummies Questions & Answers

Athlon XP + Linux/Unix? and RAM Question

Has anyone had any experience with this new processor and its compatability with Linux/Unix? How did it preform comared to regular Athlons and P4's? I also have one other question. I plan on buying a new dell and fiddling left and right with it. Which type of RAM is better, RDRAM or... (3 Replies)
Discussion started by: KyPeN
3 Replies
Login or Register to Ask a Question