LinuxÓÃNasmÇÉ»ã±à
Ëæ×ÅLinuxµÄÆÕ¼°£¬ÈçºÎÔÚLinuxƽ̨ϽøÐбà³Ì£¬ÓÈÆäÊÇ»ã±à³ÉΪ´ó¼Ò¹Ø×¢µÄÒ»¸öÎÊÌ⣬µ«ÊÇÕâ·½Ãæ×ÊÁÏÈ´ºÜÉÙ¡£ÔÚ±é·ÃÍøÕ¾ºÍÂÛ̳ºó£¬ÎÒ°ÑÊÕ¼¯µ½µÄ×ÊÁϽáºÏ±¾ÈË×ܽáµÄһЩ¾Ñé¸ú´ó¼Ò·ÖÏíһϡ£
Nasm½éÉÜ
LinuxϵĻã±à±àÒëÆ÷ÓжàÖÖ£¬Óï·¨Ò²²»¾¡Ïàͬ£¬ÆäÖÐGASÊDZȽϻù±¾µÄ»ã±à¹¤¾ß¡£µ«ÊÇGAS²ÉÓõIJ»ÊÇÎÒÃÇͨ³£ÔÚDOSÌåϵÏÂʹÓõĻã±àÓï·¨£¬Ëü²ÉÓõÄÊÇAT&TµÄÓï·¨¸ñʽ£¬ÕâÊǼ̳ÐUnixµÄÌص㣬ÓëIntelÓï·¨¸ñʽÓкܴóµÄ²»Í¬¡£
×÷Ϊһ¸ö´ÓDOSתÐ͵½LinuxµÄ»ã±à°®ºÃÕߣ¬AT&TµÄ¸ñʽ²»Ì«ÈÝÒ×½ÓÊÜ£¬Ñ§Ï°ÆðÀ´Ò²·Ç³£À§ÄÑ¡£ÎÒÒª½éÉܵÄÊÇÁíÒ»ÖÖ»ã±à¹¤¾ßNasm£¬Õâ¸úDOSÏÂÓõÄIntel x86»ã±à·ç¸ñµÄMasmÀàËÆ£¬ÊÇLinuxÖÐÓï·¨ÓëDOS×îΪÏàÏñµÄÒ»ÖÖ»ã±à¹¤¾ß¡£
ÏÂÃæ¾ÍÒÔhello.asmÕâ¸öС³ÌÐòΪÀý£¬½éÉÜÈçºÎÓÃNasmÔÚLinuxϽøÐлã±à¡£
hello.asm
hello world for Linux
section .text
extern puts
global main
main:
push dword msge ;
call puts ;
add esp, byte 4 ;
ret ;
msge:
db “Hello World!”,0
Nasm±àÒëÃüÁîÈçÏ£º
Nasm -f elf hello.asm
gcc -o hello hello.o
“Nasm -f elf hello.asm”Êǽ«°Ñhello.asm»ã±à³Éelf objectÎļþ¡£“gcc -o hello hello.o”»á°Ñhello.asm»ã±à³É¶þ½øÖÆ¿ÉÖ´ÐÐÎļþhello.com ¡£
Nasm -fÃüÁîµÄ²ÎÊýÖ÷ÒªÓÐaoutºÍelfÁ½ÖÖ£¬Èç¹û²»ÄÜÈ·¶¨LinuxϵͳӦ¸ÃÓÃaout»¹ÊÇelf£¬¿ÉÒÔÔÚNasmĿ¼ÖÐÊäÈëÃüÁîfile Nasm£¬Èç¹ûÊä³ö“Nasm: ELF 32-bit LSB executable i386(386 and up) Version 1”Ó¦¸ÃʹÓÃelf£»Èç¹ûÊä³ö“Nasm: Linux/i386 demand-paged executable(QMAGIC) ”Ó¦¸ÃʹÓÃaout¡£ÓÃÃüÁîNasm -h¿ÉÒÔÈ¡µÃNasmÃüÁîÐеÄÍêÕû˵Ã÷¡£
³ÌÐò˵Ã÷
hello.asmÊǵ÷ÓÃÁËLinuxϵͳµÄputsº¯Êý£¬ÔÀíÓëµ÷ÓÃDOSÏÂCÓïÑԵĺ¯ÊýÏàͬ£¬ÏÈÓÃexternÉùÃ÷putsÊÇÍⲿº¯Êý£¬ÔٰѲÎÊý£¨¼´msgµÄµØÖ·£©Ñ¹Èë¶ÑÕ»£¬×îºócallº¯ÊýʵÏÖÊä³ö¡£ ÔÙÀ´¿´Ò»¸ö³ÌÐò£º
section .text
global main
main:
mov eax,4 ; 4ºÅµ÷ÓÃ
mov ebx,1 ; ebxËÍ1±íʾÊä³ö
mov ecx,msge ; ×Ö·û´®µÄÊ×µØÖ·ËÍÈëecx
mov edx,14 ; ×Ö·û´®µÄ³¤¶ÈËÍÈëedx
int 80h ; Êä³ö×Ö´®
mov eax,1 ; 1ºÅµ÷ÓÃ
int 80h ; ½áÊø
msge:
db “Hello World!”,0ah,0dh
Õâ¸ö³ÌÐòÓëDOS³ÌÐòÊ®·ÖÏàËÆ£¬¶øÇÒ½á¹ûͬhello.asmÒ»Ñù£¬ËüÓõÄÊÇLinuxÖеÄ80hÖжϣ¬Ï൱ÓÚDOSϵÄ21hÖжϣ¬Ö»ÊÇÒòΪLinuxÊÇ32λ²Ù×
Ïà¹ØÎĵµ£º
×ÜÀÀ
ÓÃiptables -ADC À´Ö¸¶¨Á´µÄ¹æ
Ôò
£¬-AÌí¼Ó -Dɾ³ý -C ÐÞ¸Ä
iptables - [RI] chain rule num rule-specification[option]
ÓÃiptables - RI ͨ¹ý¹æÔòµÄ˳ÐòÖ¸¶¨
iptables -D chain rule num[option]
ɾ³ýÖ¸¶¨¹æÔò
iptables -[LFZ] [chain][option]
ÓÃiptables -LFZ Á´Ãû [Ñ¡Ïî]
iptables -[NX] chain
ÓÃ -NX ......
ʹÓÃdfºÍduÃüÁîÀ´¼à¿ØÎļþϵͳµÄÓÐЧ¿Õ¼äµÄ´óС
ͨ¹ýÇå³ý²»ÓõÄÎļþºÍcoreÎļþÀ´ÇåÀíÎļþϵͳ¿Õ¼ä
ͨ¹ýÐÞ¼ôÈÕÖ¾ÎļþÀ´ÇåÀí/varÎļþϵͳ
´ÓÃüÁîÐÐÀ©Õ¹Ò»¸ö¾í×é
´ÓÃüÁîÐÐÀ©Õ¹Ò»¸öÂß¼¾í
´ÓÃüÁîÐÐÀ©Õ¹Ò»¸öÎļþϵͳ
1.¼à¿Ø´ÅÅÌʹÓÃÇé¿ö
ʹÓÃdf ÃüÁî¼ì²éÎļþϵͳµÄÓÐЧ¿Õ¼ä¡£
# df -k
Filesystem kbytes used avai ......
½«ÁªÍø·½Ê½ÉèÖÃΪNAT
µÚÒ»²½£º
cdµ½/etc/sysconfig/network-scriptsϵµÄifcfg-eth0
µÚ¶þ²½£º
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
#BOOTPROTO=static
BOOTPROTO=none
BROADCAST=192.168.174.255
HWADDR=00:0C:29:F2:BB:A9
IPADDR=192.168.174.11
......
ÄÚºËÇý¶¯·ÖÀà
Çý¶¯ÊµÏÖ¹¦ÄÜ£º
¶Á
д
´ò¿ª
ÉèÖÃ
×îÖÕÄ¿µÄ²Ù×÷Ó²¼þÉ豸£ºÊý¾Ý´«ÊäºÍÊý¾Ý¿ØÖÆ
Ó²¼þ²Î¿¼ÊֲᣬÄÚºËÌṩµÄ¹¦ÄÜ£º²Ù×÷ʱÐò£¬×ÜÏßÈçºÎ²Ù×÷£¬ÄÚºËAPI
1.×Ö·ûÉ豸£¨char£©
2.¿éÉ豸£¨block£©
3.ÍøÂçÉ豸£¨net£©
ÄÚºËÄ£¿é²Ù×÷ÃüÁî
make
¼ÓÔØ:sudo modprobe ./Mo ......
Ò»£¬Ó²¼þÅäÖÃ×îµÍÒªÇó£º
32루X86£©£º
¸öÈËÈÏΪÖÁÉÙ1GÄڴ棨linux ÉÏ512M ¿ÉÒÔ£¬µ«Ì«¹ýÓÚÃãÇ¿ÁË£¬ÄÇÑùÈÝÒ×ËÀ»ú»ò¿¨×¡²»¶¯£¬»áÈÃÈË×¥¿ñµÄ;
windows 512M µÄ¿Ï¶¨²»ÐУ©
10GµÄ¿ÉÓô ......