Common network attacks

DOS, DDOS attack and Prevention
DOS denial of service attack
Exploit program, exploit the agreement to attack the server, causing the server can not properly provide services.
For example: the use of three-way handshake design flaws tcp syn flood attack
 
 
a -------syn=100---> b
a <---syn=1000,ack=101--- b
a ----syn=101,ack=1001--> b
 
 
 
DDOS distributed denial of service attack
Use a large number of puppet machine to attack the server, the server bandwidth in excess of the actual processing power or even exceed the room, causing the server can not properly provide services.
 
 
Defense: zone defense.
 
router <---XX---
Telecom router <---- room
router <--------
 
CDN network (Content Delivery Network = intelligent DNS + squid)
 
 
 
SQL Injection
Common means of server intrusion.
Filter characters using the program is not strict, leading to a malicious hacker can submit a request to query data in the database should not see.
 
 
Prevention:
Strengthen programmer relevant aspects of security awareness, avoid write code for SQL injection vulnerabilities.
Install third-party modules, security software for protection:
mod_security module
Configured for php, but sometimes after configuration may affect the proper functioning of.
# vim /etc/php.ini
...
magic_quotes_runtime = On
magic_quotes_gpc = On <--- received special symbols, especially filtration or single quotes escaped
 
 
 
php syntax:
 
Variable definitions
$a=123;
$b="uplooking";
echo $ a;
echo $ b;
 
php string concatenation symbol. ""
$c="wel to ".$b." !";
 
 
 
Html language of form
 
 
 
ARP spoofing and Prevention
ARP protocol is used in a switched network, obtain an IP address corresponding to MAC address.
 
 
Physically, they are a local area network, belong to a switched network
A <-------1 switch 2------> B
3
|
C
要让以上机器可以相互通讯,逻辑上,他们配置的IP必须是同一个网段。
 
A 10.1.1.1
B 10.1.1.2
C 192.168.1.3
 
只有A与B可以通信。
 
交换机会连接它接口的所有设备的MAC地址都记录下来,通过MAC地址决定数据帧从哪个接口发送出去
MAC地址表:
接口 MAC地址
1 A
2 B
3 C
 
 
A机器和B机器通讯:
A、B之间之前是没有任何的通信。
 
A -----> B
# ping 10.1.1.2
1、在交换网络中,发送一个ARP广播。
谁拿了10.1.1.2这个IP,把你的MAC地址告诉我,我的IP是10.1.1.1,我的MAC是A。
sip: 10.1.1.1
dip: 10.1.1.2
smac: A
dmac: FF:FF:FF:FF:FF:FF <---广播地址
 
2、B机器会对广播进行回应,使用单播回应
我是B机器,我MAC地址是B。
sip:10.1.1.2
dip:10.1.1.1
smac:B
dmac:A <--- 单播
 
 
 
ARP欺骗:
 
在物理上,他们是局域网,同属于一个交换网络
A <-------1 switch 2------> B
3
|
C
要让以上机器可以相互通讯,逻辑上,他们配置的IP必须是同一个网段。
 
A 10.1.1.1
B 10.1.1.2
C 10.1.1.3
 
C机器是中了病毒或者是黑客控制的电脑,在局域网进行ARP欺骗。
 
第一欺骗: C机器不断向A机器发ARP数据包:
我的IP是10.1.1.2,我的MAC地址是C
 
A机器的ARP缓存里就保存了以下的对应关系:
10.1.1.2 <---> MAC地址:C
 
结果: A机器要与10.1.1.2通讯,数据包会:
sip: 10.1.1.1
dip: 10.1.1.2
smac: A
dmac: C <--- 原本拿了10.1.1.2这个IP是B,但是又被被ARP欺骗了
 
 
应用场合:
假冒网关。可以实现骗取机器所有发送给网关的数据包。
 
解决: 被欺骗的机器只要静态绑定网关的MAC地址
# arp -s 10.1.1.2 AA:BB:??
 
第二欺骗:C机器不断向网关发送ARP欺骗包:
我IP是10.1.1.1 ,我的MAC是C。结果:
网关的ARP缓存里认为:
10.1.1.1 <----> C
网关把所有发送给10.1.1.1的数据包都发送给了C机器。
 
应用场合: 用在机房。
 
解决: 在路由上静态绑定网络中受害机器的MAC
arp防火墙。
 
 
 
web服务安全
 
 
 
xxx.php --> httpd ---> libphp.so ---编译页面中<?php ?>里的代码
 
 
通过对apache进行设定,可以降低webshell后门带来的损害:
 
1、通过对php模块传递参数,锁定网站所在的根目录
 
<VirtualHost *:8082>
 
DocumentRoot /share/12
ServerName 10.1.1.21
ErrorLog logs/10.1.1.21-error_log
CustomLog logs/10.1.1.21-access_log common
 
<Directory /share/12>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
 
<IfModule mod_php5.c>
php_admin_value open_basedir "/share/12:/var/lib/php/session:/tmp"
</IfModule>
</VirtualHost>
 
 
2、不允许php执行系统的命令
# vim /etc/php.ini
disable_functions = exec,shell_exec,system,passthru,popen
 
 
3、保证线上的服务器没有编译工具
 
如果不方便卸载,就把权限修改成700或者750,不允许普通帐号编译软件。
# chmod 750/usr/bin/gcc
 
 
=======================================================================
 
1、做好基本安全设定:
回顾之前的文档
 
2、留意一些系统BUG的信息。甚至可以加入一些黑客QQ群,社区,进行讨论。
 
3、做好服务器上线、下线、运维的流程。
 
4、了解你所维护机器以及上面运行的应用。
web服务器,你必须上面运行应用程序,例如discuz论坛,应该了解discuz源代码,运行所需要的条件,以及论坛行为模式。
 
 
做好日志的记录,行为模式分析。
 
5、设定正确的权限。
 
 
 
 
 
 
 
 
 
 
 

Guess you like

Origin www.cnblogs.com/steven9898/p/11329496.html