Security through obscurity

Post ways to make your code unreadable to protect it from non-autistic humans.
Rust is unreadable as it is, so don't post it here, let's keep it straight.

Thalidomide Vintage Ad Shirt $22.14

Black Rifle Cuck Company, Conservative Humor Shirt $21.68

Thalidomide Vintage Ad Shirt $22.14

  1. 1 month ago
    Anonymous

    use 1 << 20 to mean 1 MiB instead of either defining
    #define MiB 1024u * 1024u
    // 1 * MiB

    or
    constexpr
    unsigned long long int
    operator""_MiB(unsigned long long int const x) noexcept
    {
    return 1024u * 1024u * x;
    }

    // 1_MiB

    • 1 month ago
      Anonymous

      >use 1 << 20 to mean 1 MiB
      there is nothing obscure about that.
      1<<20 is just 2^20 which is how Mi is defined.

  2. 1 month ago
    Anonymous

    i think obfuscating your source is a bad idea.
    it makes coding harder
    you can protect your source just by airgapping your machine
    and once compiled, then disassembled, your obfuscation efforts become moot or you have a runtime cost attached to it.

    i think a better way of doing things would be self modifying code:
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/mman.h>

    int permichange(void *addr, size_t size)
    {
    int page_size = getpagesize();
    unsigned long rest = (unsigned long)addr % page_size;
    size += rest;
    addr -= rest;

    if(mprotect(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC) == -1)
    {
    return -1;
    }

    return 0;
    }

    void copey(unsigned char *from, unsigned char *to, size_t size)
    {
    while (size--)
    {
    to[size] = from[size];
    }
    }

    void fun_0(void)
    {
    fprintf(stderr, "fun_0n");
    }

    void fun_1(void)
    {
    fprintf(stderr, "fun_1n");
    }

    void (fun)(void)
    {
    fun_0();
    fun_1();
    }

    int main(void)
    {
    void *fun_addr = (void *)fun;
    unsigned char fun_text_test[] = "xc3";
    unsigned char fun_text[] = "x55"
    "x48x89xe5"
    "xe8xadxffxffxff"
    "x90"
    "x5d"
    "xc3";
    fun();
    permichange(fun_addr, sizeof(fun_text) - 1);
    copey(fun_text, fun_addr, sizeof(fun_text) - 1);
    fprintf(stderr, "fun aftern");
    fun();
    }

    this code is not gonna work as-is if youre not running loonix on an amd gpu
    youre basically changing the permisisons of your code to be writable with mprotect() abd then just overwrite the code with fun_text

    • 1 month ago
      Anonymous

      >amd gpu
      amd *cpu. im still half asleep

      • 1 month ago
        Anonymous

        (and i think i compiled it with -O3. dont expect it to work unless you compile once, then look at the code, find what you want to modify, shove the modified version into fun_text, compile a second time bc the adressing of your program changed, bc the contents of fun_text changed, check the real addresses for what you want to modify, modify the addresses in fun text, and compile a final time.)

    • 1 month ago
      Anonymous

      >mprotect()
      Any kind of OS specific syscall makes the program OS dependent. Just implementing current time requires you to check each syscall for time works and using the one that does, or a function that basically does the same thing.

  3. 1 month ago
    Anonymous

    I don't use spaces (except indents) or blank lines in my code. I find it easier to read that way but most people hate me for it.
    I also tend to merge lines with ; if the are closely related.

    • 1 month ago
      Anonymous

      >t. q dev

  4. 1 month ago
    Anonymous

    WHY???
    Coding already is hard enough.
    You understand the pattern if you can explain it with easy word.

  5. 1 month ago
    Anonymous

    Any formatter mogs you

  6. 1 month ago
    Anonymous

    homie ever heard of hashing, RSA and AES?

  7. 1 month ago
    Anonymous

    #include<iostream>
    #include<format>
    #include<stdexcept>

    #define let auto
    #define fn auto
    #define i32 int
    #define println(fmt, ...) std::cout << std::format(fmt __VA_OPT__(,) __VA_ARGS__) << 'n';

    template <class T> class Option {
    protected:
    const T _inner = 0;
    const bool _is_some;
    Option() : _is_some{false} {}
    Option(T value) : _inner{value}, _is_some{true} {}
    public:
    [[nodiscard]] virtual T unwrap() {
    [[likely]] if (_is_some) return _inner;
    throw std::logic_error("called unwrap() on None");
    }
    };

    template<class T> class Some : public Option<T> {
    public:
    Some(T value) : Option<T>(value) {}
    [[nodiscard]] constexpr T unwrap() noexcept override { return this->_inner; }
    };

    fn f() -> Option<i32> {
    return Some(123);
    }

    fn main() -> i32 {
    let x = f();
    println("x = {}", x.unwrap());
    return 0;
    }

    • 1 month ago
      Anonymous

      This. Just fill your code with C++ template crap and no one will ever want to look at it.

      • 1 month ago
        Anonymous

        >template crap
        You'd rather do manual monomorphization?

        • 1 month ago
          Anonymous

          yeah he'd rather replace templates with shitty python scripts that emit buggy C code instead

    • 1 month ago
      Anonymous

      We all agree Rust syntax is horrible. Here's a list of the major problems and how to fix them, and then maybe people will actually use it someday.
      1. No block expressions. No implicit returns. Use the fricking keyword.
      2. Take the colon out of declaration syntax. remove the question mark operator. Give us a real ternary operator.
      3. Take the "!" out of macros. They should look exactly like function calls.
      4. Take the pipe bullshit out of closures. Use balanced delimiters.
      5. Take out the "::" that sometimes appears when using templates. There is no reason for having this.
      6. Fix all the keywords that were renamed for no reason: "match" = "switch," "let" = "auto," "()" = "void," and so on.
      7. Replace the stupid "=>" operator with real case labels so IDEs can actually highlight them.
      8. Make mutability the default. Use explicit const for immutable variables and references.
      9. Put the type before the variable, not after.
      10. Remove the pointless "fn" keyword. It's redundant.
      11. Put template parameters before the associated declaration instead of mixing them in with a bunch of other stuff where it's impossible to read.
      12. Change "self" back to "this" and make it implicit.
      13. Struct fields should be defined with the same syntax as declaring variables.
      14. Remove "impl Bar for Foo." You should be able to see all the interfaces a type inherits from at the declaration site.
      15. Remove "impl Foo." Methods should be defined inside the struct body, or declared there and defined at the top level.
      16. Make parentheses mandatory in if/while/for statements. Make braces optional.
      17. Bring back the three-part for loop syntax. There are things that simply can't be expressed without it.
      18. Make lifetimes completely invisible. They're implicit some of the time. Make them implicit all of the time, or just remove them. If the compiler can't make this work without a bunch of arcane symbols the programmer has to type, there is no point even having the feature.

  8. 1 month ago
    Anonymous

    > had to make a login system in... PHP
    > shared hosting in Bosnia
    > md5 hashing already then some 15 years ago was breakable on consumer hardware, anything else was slow as frick
    > idea.sqlite
    > generate 8 random hex chars
    > salt the password with them
    > store the salt concatenated with everything but the first 8 chars of salted hash as "hash"
    > when authenticating, compare the parts of the calculated hash, salted with the first 8 chars of hash stored in database, with the rest of the stored hash
    I is genios

  9. 1 month ago
    Anonymous

    >Post ways to make your code unreadable to protect it from non-autistic humans.
    Put it in a ZIP file. Change the file extension. BOOM! "Uncrackable encryption!!!!"
    Don't forget just how stupid normies really are.

  10. 1 month ago
    Anonymous

    tried to post some obfuscated code but cloudflare blocked it.

  11. 1 month ago
    Anonymous

    Do you know rust?

Your email address will not be published. Required fields are marked *