code-injection

Protecting mysql database from injection attacks with pdo script

给你一囗甜甜゛ 提交于 2019-12-12 00:48:57
问题 Recently, my database experienced an attack from mysql injections. I did not know about injections before this incident. However, I have been studying up on what it is and how to prevent it, but I cannot seem to get anything to work for this script when I try to add sql injection protection (it works fine on it's own). How could a pdo script like this add sql injection protection? <?php $username = $_GET["hits"]; $sq = "something"; $pu = $_GET["something"]; $jjj = "something"; $fff =

PHP - How to access pdo object from other (multiple) classes

▼魔方 西西 提交于 2019-12-12 00:42:52
问题 I am switching my MVC to use PDO (I know, overdue). My application has, in the past, used the following class hierarchy: Database.class>Main.class>User.class (each one extending the other). But before any object is created, the mysql connection was made (mysql_connect). Once the connection was open I could use Database.class as a wrapper class through which all my queries were performed. Through extention, a query in the User.class could be made simply by calling the "query" function ($this-

spring settings repository

心不动则不痛 提交于 2019-12-12 00:29:38
问题 many of my application-properties are provided by the database i would like to inject them via a repository. I wonder if this is doable with spring. I would be happy if someone could suggest a solution. The code i'm thinking about looks something liek this: @Component public class ExampleService implements Service { private PlatformSetting setting1; @Required @Qualifier("setting1") public void setSetting1(PlatformSetting setting1) { this.setting1 = setting1; } public String getMessage() {

Is it possible to inject a Windows Form application into another application as an MDI Child in VB.NET?

北城余情 提交于 2019-12-11 21:00:04
问题 I am creating a program that interacts with another program and I would like to "inject" my program into this program as an MDI Child window. Is this even possible, and if so can it be done in VB.NET? What kind of pitfalls are associated with doing this? 回答1: It could be done, in two ways, the first way, by obtaining a copy of Detours, and use pinvoke to inject your process into that parent process with MDI controller, the second way, although more dangerous, is to hook into the MDI

How to avoid mysql injections using PDO

心不动则不痛 提交于 2019-12-11 18:43:31
问题 How can I avoid mysql injections? This is the PHP file I have right now <?php include 'config.php'; $Name = $_GET['Name'] ; $sql = "Select * from tables where names =\"$Name\""; try { $dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass); $dbh->query('SET CHARACTER SET utf8'); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh->query($sql); $names = $stmt->fetchAll(PDO::FETCH_OBJ); $dbh = null; echo '{"key":'. json_encode($names) .'}'; } catch

Why mysql_real_escape_string() did not prevent hack?

十年热恋 提交于 2019-12-11 18:24:14
问题 I've a website that hacked today. Server logs returned something like this as hacker's tries: www.site.com/notifications.php?PID=7&id=999999.9%20union%20all%20select%20%28select%20distinct%20concat%280x7e%2C0x27%2Cunhex%28Hex%28cast%28schema_name%20as%20char%29%29%29%2C0x27%2C0x7e%29%20from%20%60information_schema%60.schemata%20limit%201%2C1%29%2C0x31303235343830303536%2C0x31303235343830303536%2C0x31303235343830303536-- But I've used mysql_real_escape_string() in my code: if (isset($_GET['id'

GWT Guice/Gin on the server side problem

↘锁芯ラ 提交于 2019-12-11 14:25:18
问题 Hi guys with my question. A GWT project, as i have read Gin i usable only on the client side than Guice is usable on the server side. Here is my question. Let first post some example code. Server side. public class WebchargeServiceImpl extends RemoteServiceServlet implements WebchargeService { @Inject private Injector injector; @Inject private ExecuteOperations executeOperations; ..... executeOperations.do(); .... Here is the injected class ExecuteOperations @Singleton public class

Remove, replace or disable dynamically-generated ASP.Net js code

和自甴很熟 提交于 2019-12-11 11:54:26
问题 I am working with a few .Net 4.0 webforms controls such as the Menu control and while I think it's great that I can now declare the way in which controls are rendered (i.e. as either tables or divs), I can't switch off the automagically-included javascript that manages the hover events for those controls, for example: new Sys.WebForms.Menu({ element: 'NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false } This appears at the bottom of every page that

How to inject a logging statement before every catch block in java

ⅰ亾dé卋堺 提交于 2019-12-11 10:03:31
问题 I initially started with Aspect Oriented Programming using JBoss , and have implemented their code injection for - Before and After the method gets called and After the Method Throws an Exception. Now i want to know how do we inject code within the method ? I want to inject a Logging statement before every catch block gets executed , How do we do that using java ? 回答1: I do not know much about JBoss AOP, but in any case you can use AspectJ because it features a handler() pointcut. Driver

avoid javascript injection while maintaining HTML?

别来无恙 提交于 2019-12-11 09:42:19
问题 $("#id").append(dataHtml); when injected with <script>alert('test)</script> an alert box appears on the screen showing test.I encoded the html but then it appeared as plain text. I get the value of dataHtml from database.Because of some reasons I have to do this all on the client side using javascript/jquery. How do i ignore such tags/injection while maintaing the html? 回答1: you could just use a simple regular expression to remove all script tags: dataHtml = dataHtml.replace(/<script.*>[\s\S]