- 1
http://blog.extremehacking.org/blog/2017/07/31/hungarian-hacker-arrested-pressing-f12/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+4
http://blog.extremehacking.org/blog/2017/07/31/hungarian-hacker-arrested-pressing-f12/
Вкратце: в Будапеште за миллион баксов набыдлокодили систему продажи билетов на общественный транспорт с кучей багов, как например поле с суммой было readonly, но если поправить html в браузере, то можно цену поменять, а на бэкенде никто не стал проверку суммы делать. Пацанчик этот баг нашел, написал в саппорт, а через 2 недели его мусора загребли.
+4
// Consumer
$channel->run(
new GracefulHandler(
new LoggingHandler(
new AcknowledgingHandler(
new JsonDecodingHandler(
new ValidatingHandler(
new DbalReconnectingHandler(
new AmqpPublishingHandler(
new Mailman($channel, $exchangeName),
new PrintNodePrinterPool(
new PluginClient(
new HttpClient(),
[new AuthenticationPlugin(new BasicAuth($key, ''))]
),
MessageFactoryDiscovery::find()
),
new DbalBatchFactory(
$connection,
new S3BatchLabelFactory(
new S3Client(
[
'version' => 'latest',
'region' => $region,
'credentials' => [
'key' => $key,
'secret' => $secret,
],
]
),
$bucket,
$logger
),
new LabelFactory(
new GuzzleClient(),
new PickTicketFactory($template, $layouts)
)
)
),
$connection
),
__DIR__ . '/schema.json'
)
)
),
$logger
)
),
$name
);
Пример consumer на PHP для RabbitMQ (Yegor OOP style)
+4
def do_creaprim(self, mesh, objname, addondir):
global message
objname = objname.replace(".", "")
objname = objname.replace(" ", "_")
bm = bmesh.new()
bm.from_mesh(mesh)
try:
txt = bpy.data.texts[str.lower("add_mesh_" + objname) + ".py"]
txt.clear()
except:
txt = bpy.data.texts.new("add_mesh_" + str.lower(objname) + ".py")
strlist = []
strlist.append("bl_info = {\n")
strlist.append("\"name\": \"" + objname + "\", \n")
strlist.append("\"author\": \"Gert De Roost\",\n")
strlist.append("\"version\": (1, 0, 0),\n")
strlist.append("\"blender\": (2, 65, 0),\n")
strlist.append("\"location\": \"Add > Mesh\",\n")
strlist.append("\"description\": \"Create " + objname + " primitive.\",\n")
strlist.append("\"warning\": \"\",\n")
strlist.append("\"wiki_url\": \"\",\n")
strlist.append("\"tracker_url\": \"\",\n")
strlist.append("\"category\": \"Add Mesh\"}\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("if \"bpy\" in locals():\n")
strlist.append(" import imp\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("import bpy\n")
strlist.append("import bmesh\n")
strlist.append("import math\n")
strlist.append("from mathutils import *\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("class " + objname + "(bpy.types.Operator):\n")
strlist.append(" bl_idname = \"mesh." + str.lower(objname) + "\"\n")
strlist.append(" bl_label = \"" + objname + "\"\n")
strlist.append(" bl_options = {\'REGISTER\', \'UNDO\'}\n")
strlist.append(" bl_description = \"add " + objname + " primitive\"\n")
strlist.append("\n")
strlist.append(" def invoke(self, context, event):\n")
strlist.append("\n")
strlist.append(" mesh = bpy.data.meshes.new(name=\"" + objname + "\")\n")
strlist.append(" obj = bpy.data.objects.new(name=\"" + objname + "\", object_data=mesh)\n")
strlist.append(" scene = bpy.context.scene\n")
strlist.append(" scene.objects.link(obj)\n")
strlist.append(" obj.location = scene.cursor_location\n")
strlist.append(" bm = bmesh.new()\n")
strlist.append(" bm.from_mesh(mesh)\n")
strlist.append("\n")
strlist.append(" idxlist = []\n")
posn = 0
strlist.append(" vertlist = [")
for v in bm.verts:
if posn > 0:
strlist.append(", ")
posn += 1
strlist.append(str(v.co[:]))
strlist.append("]\n")
strlist.append(" for co in vertlist:\n")
strlist.append(" v = bm.verts.new(co)\n")
strlist.append(" bm.verts.index_update()\n")
strlist.append(" idxlist.append(v.index)\n")
posn = 0
strlist.append(" edgelist = [")
for e in bm.edges:
if posn > 0:
strlist.append(", ")
posn += 1
strlist.append("[" + str(e.verts[0].index) + ", " + str(e.verts[1].index) + "]")
strlist.append("]\n")
strlist.append(" for verts in edgelist:\n")
strlist.append(" try:\n")
strlist.append(" bm.edges.new((bm.verts[verts[0]], bm.verts[verts[1]]))\n")
strlist.append(" except:\n")
strlist.append(" pass\n")
posn1 = 0
strlist.append(" facelist = [(")
for f in bm.faces:
if posn1 > 0:
strlist.append(", (")
posn1 += 1
posn2 = 0
for v in f.verts:
if posn2 > 0:
strlist.append(", ")
strlist.append(str(v.index))
posn2 += 1
strlist.append(")")
strlist.append("]\n")
strlist.append(" bm.verts.ensure_lookup_table()\n")
strlist.append(" for verts in facelist:\n")
Залил вам отборного
+4
function check_for_injection($_arr_check) {
$inj = 0;
foreach ($_arr_check as $n=>$v) {
$_text = "SELECT ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = " SELECT";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "DELETE ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "UPDATE ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "INSERT ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "LOAD ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "DROP ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "INTO ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "OUTFILE ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
$_text = "CALL ";
if (strpos(strtoupper($v), $_text)!==false) $inj = 1;
}
return $inj;
}
$dd = check_for_injection($_REQUEST);
if ($dd==1) die();
Надежный способ проверки на взлом
+4
// Change the color of the displayed status
if ($status == "active") {
$status_display = '<font color="white">' . $status . '</font>';
} elseif ($status == "sold") {
$status_display = '<font color="green">' . $status . '</font>';
} elseif ($status == "emis") {
$status_display = '<font color="orange">' . $status . '</font>';
} elseif ($status == "alert") {
//
} elseif ($status == "deleted") {
$status_display = '<font color="white">' . $status . '</font>';
//$style="text-decoration: line-through;";
} elseif ($status == "closed") {
$status_display = '<font color="closed">' . $status . '</font>';
} elseif ($status == "options_sent") {
$status_display = '<font color="yellow">' . $status . '</font>';
}
if ($trip_type == "one_way") {
$one_way = "SELECTED";
$round_trip = "";
$trip_type = '<font color="DarkBlue">One Way</font>';
} else {
$one_way = "";
$round_trip = "SELECTED";
$trip_type = '<font color="#348017">Round Trip</font>';
}
if ($cabin_class == "economy_class") {
$eco_class = "SELECTED";
$bus_class = "";
$ooo_class = "";
} elseif ($cabin_class == "business_class") {
$eco_class = "";
$bus_class = "SELECTED";
$ooo_class = "";
} elseif ($cabin_class == "o_class") {
$eco_class = "";
$bus_class = "";
$ooo_class = "SELECTED";
}
if ($num_pass == "1") {
$n1 = "SELECTED";
$n2 = "";
$n3 = "";
$n4 = "";
$n5 = "";
$n6 = "";
$n7 = "";
$n8 = "";
$n9 = "";
$n10 = "";
} elseif ($num_pass == "2") {
$n1 = "";
$n2 = "SELECTED";
$n3 = "";
$n4 = "";
$n5 = "";
$n6 = "";
$n7 = "";
$n8 = "";
$n9 = "";
$n10 = "";
} elseif ($num_pass == "3") {
$n1 = "";
$n2 = "";
$n3 = "SELECTED";
$n4 = "";
$n5 = "";
$n6 = "";
$n7 = "";
$n8 = "";
$n9 = "";
Вот почему не надо мелочиться. И нанимать нормальных программистов.
+4
var options = [<?php echo implode(',', range(App\Service\Service::CONSTANT_MIN, App\Service\Service::CONSTANT_MAX)); ?>];
+4
bool shift = keys.Shift;
if (keys.Control)
{
return SelectNextControl(shift ? false : true);
}
Телерик опять жжот. Цветёт и пахнет.
+4
public class LoadingActivity extends AppCompatActivity{
if (LoadActivity.this != null && delayFlag) {
//do something
}
}
+4
import java.util.Scanner;
import java.io.*;
public class Multiply {
public static int multiplyNumbers(int n, int m)
{
int i = 0, result = 0;
for(i = 0; i < m; i ++)
result += n;
return result;
}
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
int n,m,ans;
n = sc.nextInt();
m = sc.nextInt();
ans = multiplyNumbers(n,m);
System.out.println(ans);
}
}
+4
void delslovo(char *a)
{
static int i = 0;
static bool j = false;
if (a[i++] != '\0') delslovo(a);
else i--;
if (!j)
{
if (a[i] != ' '&&a[i] != '\n'&&a[i] != '\0')
{
j = true;
i++;
}
}
if (j)
{
if (a[i - 1] == ' ') return;
a[i - 1] = a[i];
}
i--;
}
вот так надо удалять последнее слово из строки