www cto9 com(关于struts 2为什么会有代码执行漏洞的小帖子)

本文目录
关于struts 2为什么会有代码执行漏洞的小帖子
Struts结构
把里面的例子在tomcat里部署一下,就可以测试了。简单说一下struts 2的结构。
struts 2的安装是在web.xml里添加这样的一句,将Struts2所带的过滤器org.apache.struts2.dispatcher.FilterDispatcher配置到工程的web.xml文件中,默认情况下,该过滤器拦截请求字符串中以.action结尾的请求,并将该请求委托给指定的Action进行处理
《filter》
《filter-name》struts2《/filter-name》
《filter-class》org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter《/filter-class》
《/filter》
《filter-mapping》
《filter-name》struts2《/filter-name》
《url-pattern》/*《/url-pattern》
《/filter-mapping》
关于action的定义是在struts.xml中,其中《default-action-ref》是所有action都捕获不到时的选项。
《result type="redirectAction"》的作用是捕获到该action重定向到其他页面。
最后include了另外一个XML
《package name="default" namespace="/" extends="struts-default"》
《default-action-ref name="index" /》
《global-results》
《result name="error"》/error.jsp《/result》
《/global-results》
《global-exception-mappings》
《exception-mapping exception="java.lang.Exception" result="error"/》
《/global-exception-mappings》
《action name="index"》
《result type="redirectAction"》
《param name="actionName"》HelloWorld《/param》
《param name="namespace"》/example《/param》
《/result》
《/action》
《/package》
《include file="example.xml"/》
这个example.xml定义了action的具体实现,最后一个action通配符这里{1}代表了第一个通配符所匹配到的字符串。
《package name="example" namespace="/example" extends="default"》
《action name="HelloWorld" class="example.HelloWorld"》
《result》/example/HelloWorld.jsp《/result》
《/action》
《action name="Login_*" method="{1}" class="example.Login"》
《result name="input"》/example/Login.jsp《/result》
《result type="redirectAction"》Menu《/result》
《/action》
《action name="*" class="example.ExampleSupport"》
《result》/example/{1}.jsp《/result》
《/action》
《!-- Add actions here --》
《/package》
OGNL语法
struts使用了OGNL,虽然不知道为什,但是OGNL还是很强大的。
关于它的特性可以看下面的几个页面
《div class="dp-highlighter bg_html"》
When using Struts 2 token mechanism for CSRF protection, token check may be bypassed by misusing known session attributes
2015openstack win7镜像怎么制作
镜像制作方法一:
centos6.5镜像制作:(首先将CentOS-6.5-x86_64-minimal.iso镜像拷贝到/home下面)
1:
qemu-img create -f qcow2 /home/ttxImg/ttx_centos6.5.img 2.8G
2:
virt-install --connect qemu:///system -n ttx_centos6.5 -r 1024 --vcpus=2 --disk path=/home/ttxImg/ttx_centos6.5.img -c /home/ttxImg/CentOS-6.5-x86_64-minimal.iso --vnc --vncport=5914 --vnclisten=0.0.0.0 --noautoconsole --os-type linux --network=bridge:br100 --hvm --noautoconsole
windows7镜像制作:
qemu-img create -f qcow2 /home/ttxImg/ttx_win7.qcow2 40000M
virt-install --connect qemu:///system -n ttx_win7 -r 2048 --vcpus=2 --disk path=/home/ttxImg/ttx_win7.qcow2,bus=virtio,format=qcow2,cache=writeback --disk path=/home/ttxImg/virtio-win-0.1-81.iso,device=cdrom,perms=ro --force -c /home/ttxImg/win7_x86_64.iso --vnc --vncport=5914 --vnclisten=0.0.0.0 --noautoconsole --os-type windows --os-variant=win7 --network=bridge:virbr0 --hvm --noautoconsole
注:假若安装系统时,磁盘损坏,则可以将上述bus=virtio修改为bus=ide
若是还找不到,使用如下命令:
virt-install --connect qemu:///system -n neokylin_lst -r 1024 --vcpus=2 --disk path=/neokylinlst.qcow2,bus=virtio,format=qcow2,cache=writeback --force -c /home/neokylin.iso --vnc --vncport=5914 --vnclisten=0.0.0.0 --noautoconsole --os-type linux --network=bridge:virbr0 --hvm --noautoconsole
使用virtio网卡驱动:
virt-install --connect qemu:///system -n ttx_win7 -r 2048 --vcpus=2 --disk path=/home/ttxImg/ttx_win7.qcow2,bus=virtio,format=qcow2,cache=writeback --disk path=/home/ttxImg/virtio-win-0.1-81.iso,device=cdrom,perms=ro --force -c /home/ttxImg/win7_x86_64.iso --vnc --vncport=5914 --vnclisten=0.0.0.0 --noautoconsole --os-type windows --os-variant=win7 --network=bridge:virbr0,model=virtio --hvm --noautoconsole
《interface type=’bridge’》
《mac address=’52:54:00:ac:9c:4c’/》
《source bridge=’br1’/》
《target dev=’vnet3’/》
《model type=’virtio’/》
《alias name=’net3’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x08’ function=’0x0’/》
《/interface》
windows镜像上传命令:
glance add name="windows" is_public=true container_format=ovf disk_format=qcow2 《 windowsxp.img
centos镜像上传命令:
glance image-create --name centos --is-public true --container-format ovf --disk-format qcow2 《 /home/agen/centos63.img
centos镜像上传命令:
glance add name=centos_6.2_ramdisk disk_format=ari container_format=ari is_public=True 《 initrd-2.6.32-220.el6.x86_64.img
输出:Added new image with ID: 9
以上命令是先上传镜像的ramdisk文件,注意类型必须是ari
glance add name=centos_6.2_kernel disk_format=aki container_format=aki is_public=True 《 vmlinuz-2.6.32-220.el6.x86_64
输出:Added new image with ID: 10
以上命令是上传镜像的kernel文件,格式必须是aki
glance add name=centos_6.2_final disk_format=ami container_format=ami is_public=True ramdisk_id=9 kernel_id=10 《 centos_6.2_final.img
以上命令是上传主要镜像文件,格式必须是ami,ramdisk_id是刚上传的ramdisk的id,kernel_id同理。
镜像制作方法二:
1、将iso镜像文件转换为img镜像
qemu-img convert -f raw CentOS_6.2_Final64bit.iso /home/createvm/test.img
2、创建配置文件setup.xml
《domain type=’kvm’ id=’21’》
《name》test_mini_centos《/name》
《uuid》7e7f54d0-4b62-7c5e-d385-ed72473a5785《/uuid》
《memory》1048576《/memory》
《currentMemory》1048576《/currentMemory》
《vcpu》1《/vcpu》
《os》
《type arch=’x86_64’ machine=’pc-0.14’》hvm《/type》
《boot dev=’hd’/》
《/os》
《features》
《acpi/》
《apic/》
《pae/》
《/features》
《clock offset=’utc’/》
《on_poweroff》destroy《/on_poweroff》
《on_reboot》restart《/on_reboot》
《on_crash》restart《/on_crash》
《devices》
《emulator》/usr/libexec/qemu-kvm《/emulator》
《disk type=’file’ device=’disk’》
《driver name=’qemu’ type=’raw’ cache=’none’/》
《source file=’/var/lib/libvirt/images/test_mini_centos.img’/》
《target dev=’vda’ bus=’virtio’/》
《alias name=’virtio-disk0’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x05’ function=’0x0’/》
《/disk》
《disk type=’block’ device=’cdrom’》
《driver name=’qemu’ type=’raw’/》
《target dev=’hdc’ bus=’ide’/》
《readonly/》
《alias name=’ide0-1-0’/》
《address type=’drive’ controller=’0’ bus=’1’ unit=’0’/》
《/disk》
《controller type=’ide’ index=’0’》
《alias name=’ide0’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x01’ function=’0x1’/》
《/controller》
《interface type=’bridge’》
《mac address=’52:54:00:7a:d2:93’/》
《source bridge=’br0’/》
《target dev=’vnet1’/》
《model type=’virtio’/》
《alias name=’net0’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x03’ function=’0x0’/》
《/interface》
《serial type=’pty’》
《source path=’/dev/pts/0’/》
《target port=’0’/》
《alias name=’serial0’/》
《/serial》
《console type=’pty’ tty=’/dev/pts/0’》
《source path=’/dev/pts/0’/》
《target type=’serial’ port=’0’/》
《alias name=’serial0’/》
《/console》
《input type=’tablet’ bus=’usb’》
《alias name=’input0’/》
《/input》
《input type=’mouse’ bus=’ps2’/》
《graphics type=’vnc’ port=’5901’ autoport=’yes’/》
《sound model=’ich6’》
《alias name=’sound0’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x04’ function=’0x0’/》
《/sound》
《video》
《model type=’cirrus’ vram=’9216’ heads=’1’/》
《alias name=’video0’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x02’ function=’0x0’/》
《/video》
《memballoon model=’virtio’》
《alias name=’balloon0’/》
《address type=’pci’ domain=’0x0000’ bus=’0x00’ slot=’0x06’ function=’0x0’/》
《/memballoon》
《/devices》
《/domain》
3、virsh define setup.xml //创建虚拟机 查看当前系统所有的虚拟机信息:virsh list --all
4、virsh start vm_name //启动你创建的相应名字的虚拟机
注意:假若出现br0 没有此设备则使用sudo /usr/sbin/brctl addbr br0命令
qemu-img create -f raw /home/ttxImg/centos6.5_openstack_ttx.img 3000M
virt-install -n CentOS6.5-openstack-ttx -r 2048 --cpu host -c /home/ttxImg/CentOS-6.5-i386-minimal.iso --disk path=/home/ttxImg/centos6.5_openstack_ttx.img,device=disk,bus=virtio,size=10,format=qcow2 --vnc --vncport=5908 --vnclisten=0.0.0.0 -v --network bridge=br0
用 vncviewer 登录后按照屏幕提示完成 CentOS 安装。需要注意的是在分区阶段把 10GB 硬盘全部划分成一个 ext4 root 分区,不要创建多个分区也不要创建 swap 区:
$ vncviewer 172.16.39.111:5900
安装完后会自动重启,如果没有重启的话按照下面的命令启动刚刚安装好的虚拟机镜像 centos.img,如果出现 failed to find romfile “pxe-rtf8139.bin” 的错误提示可以通过安装 kvm-pxe 解决:
$ sudo qemu-kvm -m 512 -drive file=centos.img -boot c -net nic -net user -nographic -vnc :10
kvm: pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"
$ sudo apt-get install kvm-pxe
再次用 vnc 登录虚拟机镜像,安装一些必要工具(因为这个镜像将会是模板,所以最好保持最简最小化):
$ vncviewer 172.16.39.111:5900
# yum update
# yum upgrade
# yum install openssh-server
# chkconfig sshd on
修改分区加载表(/etc/fstab),注释或删除以前的,加上 LABEL=cec-rootfs 一行:
# vi /etc/fstab
#UUID=47a90bea-2d88-4c82-a335-09c1533b1538 / ext4 defaults 1 1
LABEL=cec-rootfs / ext4 defaults 0 0
在网络接口配置里面注释或删除这行 #HWADDR= 一行,启用 DHCP:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
#HWADDR="00:11:22:12:34:56"
#NM_CONTROLLED="yes"
BOOTPROTO=dhcp
ONBOOT="yes"
注射 ssh key 以便外界可以用 ssh -i mykey.priv root@host 的形式无密码登录到虚拟机实例,在 /etc/rc.local 文件中加入下面这些:
# vi /etc/rc.local
...
mkdir -p /root/.ssh
echo 》》 /root/.ssh/authorized_keys
curl -m 10 -s 需要两个virtio驱动,一个是硬盘的,一个是网卡的,即:virtio-win-0.1-30.iso和virtio-win-1.1.16.vfd
1
wget http://autosetup1.googlecode.com/files/virtio-win-1.1.16.vfd
2
wget http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-30.iso
下载一个win7的镜像,默认的名字太长了,修改短一点
1
mvcn_windows_7_professional_vl_build_x86_dvd_x15-71025.iso win7.iso
创建一个win7的镜像,raw格式,大小7G
www.2cto.com
1
kvm-img create -f raw win7.img 7G
启动基于win7的kvm虚拟机,映射驱动vfd到软盘A
1
kvm -m 1024 -cdrom win7.iso -drivefile=win7.img,if=virtio,boot=on -fda virtio-win-1.1.16.vfd -boot d -nographic -vnc 10.1.6.228:8
用vnc安装win7,因为默认没有virtio驱动,所以识别不了硬盘,需要手动选择,整个过程如下:
选择键盘

更多文章:
为什么韩国能连续九次进入世界杯?世界杯韩国是哪一年打进四强的
2025年12月7日 05:15
手机qq下载的文件在哪个文件夹,荣耀手机qq下载的文件在哪个文件夹
2025年5月13日 01:32
microsoft office excel 2007(excel2007是免费的吗)
2026年6月15日 11:40
altium designer 10(altium designer 10安装)
2025年5月18日 06:10
海马苹果助手ios版下载(封神召唤师ios版怎么在电脑上玩 封神召唤师苹果电脑版使用教程)
2026年10月28日 22:50
wii七龙珠电光火石3(七龙珠z电光火石3电脑怎么控制(我的七龙珠z电光火石3是WII的))
2025年5月10日 14:50
448800青苹果电视剧扶摇,448800青苹果电视剧扶摇光荣时代
2025年4月12日 13:52
京东app下载官网免费下载(京东app下载官网免费下载电视剧对手)
2025年6月27日 21:52
9277在线视频免费观看(抖音9277是什么意思完整版歌词分享)
2025年10月25日 23:15











