Java中,Integer,Long等都是有-127~128的缓存的,利用反射: 可以达到攻击目的
Field value = Integer.class.getDeclaredField("value");
value.setAccessible(true);
value.set(42, 43);
同样,String这个“不变”对象也可以:
| dt = {} | |
| if "key" in dt: | |
| dt["key"] = 1 | |
| else: | |
| dt["key"] += 1 | |
| # 默认字典 | |
| dt = collections.defaultdict(int) | |
| dt["key"] += 1 |
| LightObject = namedtuple('LightObject', ['shortname', 'otherprop']) | |
| n = LightObject(shortname='something', otherprop='something else') | |
| n.shortname # something |
Java中,Integer,Long等都是有-127~128的缓存的,利用反射: 可以达到攻击目的
Field value = Integer.class.getDeclaredField("value");
value.setAccessible(true);
value.set(42, 43);
同样,String这个“不变”对象也可以:
| /** | |
| * 最简单的方式把一个InputStream转换成String | |
| * | |
| * @author lichengwu | |
| * @version 1.0 | |
| * @created 2013-12-28 10:37 AM | |
| */ | |
| public class InputStreamAsString { | |
| public static void main(String[] args) throws IOException { |
| #!/usr/bin/python | |
| #encoding=gbk | |
| __author__ = 'lichengwu' | |
| import pexpect | |
| import sys | |
| import getopt | |
| import time | |
| import os | |
| def run_command(ip, user, password, cmd, tmo=600): |
| #!/bin/sh | |
| DESC="Jenkins CI Server" | |
| NAME=jenkins | |
| PIDFILE=/var/run/$NAME.pid | |
| RUN_AS=admin | |
| COMMAND=JAVA_TOOL_OPTIONS=-Dfile.encoding=GBK /opt/taobao/java64/bin/java -jar -server -Xms2048m -Xmx2048m -XX:NewSize=320m -XX:MaxNewS | |
| ize=320m -XX:PermSize=128m -XX:MaxPermSize=256m /usr/lib/jenkins/jenkins.war --httpPort=9000 | |
| #COMMAND=/opt/taobao/java/bin/java -jar /home/jenkins/jenkins.war |
| /** | |
| * gc monitoring only on jdk7 or later | |
| * | |
| * @author lichengwu | |
| * @version 1.0 | |
| * @created 2013-09-14 10:44 PM | |
| */ | |
| public class GCMonitoring { |
| /** | |
| * lazy init by placeholder(thread safe) | |
| * | |
| * @author lichengwu | |
| * @version 1.0 | |
| * @created 2013-01-31 10:19 PM | |
| */ | |
| public class Resource { | |
| public static Resource getInstance() { |
| /********************************************************** | |
| mail.meituan.com | |
| @author:lichengwu | |
| @created:2013-01-11 | |
| @version:1.0 | |
| **********************************************************/ | |
| var name="Meituan Mail"; | |
| var ver="2013-01-11"; | |
| function init(){ |
| package oliver.test.conurrency; | |
| import java.util.Date; | |
| import java.util.concurrent.TimeUnit; | |
| /** | |
| * do not use build-in lock | |
| * | |
| * if a class use build-in lock ensure concurrence access it's field, thread | |
| * will be blocked by other threads who had acquired the lock. |