code-injection

PHP Code to avoid sql injection [duplicate]

非 Y 不嫁゛ 提交于 2020-01-14 07:00:08
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Best way to prevent SQL injection in PHP? This is my code $user_name = "admin"; $password = "123456"; $database = "jbit"; $server = "localhost"; $id = $_POST['id']; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SELECT * FROM jbit WHERE htno='$id'"; $result = mysql_query($SQL); $sum = "SELECT htno, SUM(tm) AS tech, ROUND

Interact with Flash using Python Mechanize

妖精的绣舞 提交于 2020-01-13 19:17:08
问题 I am trying to create an automated program in Python that deals with Flash. Right now I am using Python Mechanize, which is great for filling forms, but when it comes to flash I don't know what to do. Does anyone know how I can interact with flash forms (set and get variables, click buttons, etc.) via Python mechanize or some other python library? 回答1: Nice question but seems unfortunately mechanize can't be used for flash objects 回答2: What you probably want to search for is how to control

Constructor injection with other, non-dependency, constructor arguments

心已入冬 提交于 2020-01-13 08:19:41
问题 I'm new to IOC containers, and I'm getting started with NInject. What do you do if you want your constructor to have parameters that are not services and don't need to be instantiated by the IOC container? For example: public class Person { private readonly string _name; private readonly IPersonRepository _repository; public Person(string name, IPersonRepository repository) { _name = name; _repository = repository; } ...... } Imagine that name is a requirement of the Person class, so, to

CDI - ApplicationScoped but configured

空扰寡人 提交于 2020-01-13 07:20:33
问题 Problem Using CDI I want to produce @ApplicationScoped beans. Additionally I want to provide a configuration annotation to the injection points, e.g.: @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface Configuration { String value(); } I do not want to write a separate producer for each different possibility of value . Approach The usual way would be to make a producer and handle the injection point annotations:

CDI - ApplicationScoped but configured

安稳与你 提交于 2020-01-13 07:20:13
问题 Problem Using CDI I want to produce @ApplicationScoped beans. Additionally I want to provide a configuration annotation to the injection points, e.g.: @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface Configuration { String value(); } I do not want to write a separate producer for each different possibility of value . Approach The usual way would be to make a producer and handle the injection point annotations:

Is there a way to demonstrate SQL injection with mysqli?

只愿长相守 提交于 2020-01-11 13:26:09
问题 I want to make a quick and easy demonstration about how SQL injection work. And I've solved some of my problems. I have a table with random usernames, passwords and emails in, and I'm able to "inject" SQL code to view all of the users in a search with this injection: ' OR '1'='1 This is how my PHP code looks for searching for "members": if (isset($_POST['search'])) { $searchterm = $_POST['searchterm']; echo $searchterm . '<br>'; /* SQL query for searching in database */ $sql = "SELECT

How do I make it so my Chrome extension will only inject a script once?

徘徊边缘 提交于 2020-01-11 09:29:09
问题 I'm using programmatic injection to inject my extension's code into a page only when the browser action is clicked. This is what I have on my extension's event page (per the example in the documentation): chrome.browserAction.onClicked.addListener(function callback(tab){ chrome.tabs.executeScript(null, {file: "content-script.js"}); }); However, the way this works, the script is injected every time the button is clicked. How can I change it so that the script is not injected on subsequent

mysql injection damages?

我是研究僧i 提交于 2020-01-09 03:53:16
问题 I Just noticed that my mysql_real_escape_string function is not inside a '' in some of my php scripts and it was vulnerable to injections and things like sleep(30) executed on my production site. I am going the PDO route and implementing the prepared statements after lots of reading here. but this is not implemented yet. Few questions, I see in my logs that lots of injections where done by people online but I can not see any damages. the user that the site runs to do sql queries has update

PHP - Smart way to protect $_GET vars from malicious injection

自古美人都是妖i 提交于 2020-01-06 14:49:55
问题 I found this piece of code here: http://php.net/manual/de/reserved.variables.get.php Want to use it to make my code safer. I use quite a few $_GET var in my project. Please, if possible I would like you professionals to have a look and see if this piece of code could be enhanced or has any problems. There is a smart way to protect the $ _GET input from malicious injection and options for inserting default values: <?php // Smart GET function public function GET($name=NULL, $value=false,

Postgres bulk insert/update that's injection-safe. Perhaps a function that takes an array? [duplicate]

六月ゝ 毕业季﹏ 提交于 2020-01-06 07:19:13
问题 This question already has answers here : Improving a function that UPSERTs based on an input array (2 answers) Closed 5 months ago . I'm working on paying back some technical debt this week, and it hit me that I have no idea how to make multi-value inserts safe from accidental or malicious SQL injections. We're on Postgres 11.4. I've got a test bed to work from that includes a small table with about 26K rows, here's the declaration for a small table I'm using for testing: BEGIN; DROP TABLE IF