code-injection

guice: runtime injection/binding at command line

人走茶凉 提交于 2020-01-01 15:05:43
问题 I have the following problem: @Inject MyClass(Service service) { this.service = service; } public void doSomething() { service.invokeSelf(); } I have one module bind(service).annotatedWith(Names.named("serviceA").to(ServiceAImpl.class); bind(service).annotatedWith(Names.named("serviceB").to(ServiceBImpl.class); Now my problem is I want to allow user to dynamically choose the injection on runtime base through command line parameter. public static void Main(String args[]) { String option = args

Java ASM Bytecode Modification-Changing method bodies

六眼飞鱼酱① 提交于 2019-12-31 22:21:11
问题 I have a method of a class in a jar whose body I want to exchange with my own. In this case I just want to have the method print out "GOT IT" to the console and return true; I am using the system loader to load the classes of the jar. I am using reflection to make the system classloader be able to load classes by bytecode. This part seems to be working correctly. I am following the method replacement example found here: asm.ow2.org/current/asm-transformations.pdf. My code is as follows:

How can I safely validate an untrusted regex in Perl?

不问归期 提交于 2019-12-31 00:36:11
问题 This answer explains that to validate an arbitrary regular expression, one simply uses eval : while (<>) { eval "qr/$_/;" print $@ ? "Not a valid regex: $@\n" : "That regex looks valid\n"; } However, this strikes me as very unsafe, for what I hope are obvious reasons. Someone could input, say: foo/; system('rm -rf /'); qr/ or whatever devious scheme they can devise. The natural way to prevent such things is to escape special characters, but if I escape too many characters, I severely limit

SQL injection on INSERT

萝らか妹 提交于 2019-12-30 03:34:09
问题 The SQL Injection on INSERT as described here doesn't seem to work with MySQL. SQL injection on INSERT When I use this statement: INSERT INTO COMMENTS VALUES('122','$_GET[value1]'); With this as the 'value1' variable value: '); DELETE FROM users; -- This error gets returned: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM users; --')' at line 1 What's wrong??? PS: Someone suggested me to

AppDomain.CreateInstanceFromAndUnwrap - Unable to cast transparent proxy

穿精又带淫゛_ 提交于 2019-12-29 04:34:07
问题 I'm writing a .NET library to inject managed DLLs into external processes. My current approach is: Use CreateRemoteThread to force the target process to call LoadLibrary on an unmanaged bootstrap DLL. From this point we're executing code in the target process. My bootstrap DLL then creates an instance of the CLR and calls ExecuteInDefaultAppDomain on it, which executes a method in a managed helper DLL. This method creates a new AppDomain and calls AppDomain.CreateInstanceFromAndUnwrap to pass

DLL Injection fails with code 127

帅比萌擦擦* 提交于 2019-12-25 18:55:11
问题 I am trying to do some dll injection. I think I tried everything I could but cound not solve the problem unfortunately. I always get ERROR CODE 127 which means ERROR_PROC_NOT_FOUND. I am using Windows 7 64 bit. #include <iostream> #include <Windows.h> #include <TlHelp32.h> using namespace std; char FileToInject[] = "theDll.dll"; char ProcessName[] = "calc.exe"; typedef HINSTANCE (*fpLoadLibrary)(char*); bool InjectDLL(DWORD processId); int main() { DWORD processId = NULL; PROCESSENTRY32 pre32

Inject Jar and replace classes in running JVM

折月煮酒 提交于 2019-12-25 08:59:31
问题 I want to be able to replace and add some classes to an already running JVM. I read that I need to use CreateRemoteThread , but I don't completely get it. I read this post on how to do it (Software RnD), but I can't figure out what it does and why. Besides that, it only introduces new classes, but doesn't change existing ones. How can I do it with C++? 回答1: You don't even need CreateRemoteThread - there is an official way to connect to remote JVM and replace loaded classes by using Attach API

EJB Injection failure on deploy

爱⌒轻易说出口 提交于 2019-12-25 04:53:15
问题 I've got a problem exxh EJB's. First of all, my setup: I am using GlassFish & JEE6. I got a REST-Service packaged as a WAR and a bean packaged as an EJB-Jar. They are not inside an EAR. The EJB should be used from the REST-WAR via @EJB, but when I try to deploy the WAR, GlassFish shows this error: Error occurred during deployment: Exception while deploying the app [exx-upload-1.0] : Cannot resolve reference Local ejb-ref name=com.ex.exx.model.FileUpload/ocr,Local 3.x interface =com.ex.exx.api

How to submit a form through Javascript in an iPhone SDK application?

旧时模样 提交于 2019-12-25 04:40:34
问题 I need to post a form loaded in UIWebview (iPhone sdk/Objective c) through Javascript injection. I used document.form.submit() which is not working. 回答1: To access your form you need to pull it from the forms array. Use form's name attribute as array key . This should look like: document.forms['formName'].submit(); 来源: https://stackoverflow.com/questions/3633152/how-to-submit-a-form-through-javascript-in-an-iphone-sdk-application

HTML encoding issue in asp.net

风流意气都作罢 提交于 2019-12-25 03:56:51
问题 I have a literal control being used to display HTML coming from DB. I did face some XSS issues and implemented Anti-XSS Security Runtime Engine (SRE) to automatically encode all html markup. e.g. DB : <p align="center"></p> Anti-XSS encodes it as : <p align="center"> </p&#62 However, when I am setting text property of literal content from code behind, I was expecting that the literal control will DECODE the proper html and display the rendered version. Instead, it is showing the ENCODED