• Tim (unregistered)

    Come on Alex - we expect a bit of reverse engineering so we can at least start to understand what it's trying to do

  • Tim (unregistered)

    Come on Alex - we expect a bit of reverse engineering so we can at least start to understand what it's trying to do

  • (nodebb)

    If you use Python and the Viper architecture, do you get a new snake species?

  • (nodebb)

    I'm having a hard time understanding how this even works? It looks like 'word' is 'maxchar' long, OK. Then the length of 'List' sets the target letter for the O(n^15) loop? And only when the contents of 'lword' (which are all that target letter) match 'word' does it break? And each iteration it logs that word even if it ignores it?

    Addendum 2024-07-10 07:56: Not the length of 'List', but its integer value. And like all bad code, there's no argument validation.

  • (nodebb) in reply to colejohnson66

    Not the length of 'List', but its integer value.

    Yup. But that's just a badly named parameter. (Should be "ListLength", subject to some debate about snake_case vs PascalCase vs camelCase...)

    And like all bad code, there's no argument validation.

    Indeed. True would work OK (being interpreted as 1), but ...

    And don't forget that if you pass 'yes' for verbose, the first iteration throws a ValueError on the if int(verbose): line in the innermost loop.

    But the lines that can set end to 1 do it by comparing stringified lists, and one of the lists is a listified string. I'm pretty sure you won't find many actual experts in Python who'd call that "Pythonic".

    And overall, the function returns nothing (pendantry: None), and writes stuff into the poor text file until it reaches the first string that matches a specific pattern:

    if List is 1, the pattern is "9".

    if List is 2, the pattern is "zz".

    if List is 3, the pattern is "ZZZ".

    if List is 4, the pattern is "zzzz".

    if List is 5, the pattern is "ZZZZZ".

    if List is 6, the pattern is "ZZZZZZ".

    Now, what does it write into the text file, poor thing? Until it matches the pattern above, it writes one line of maxchar characters for each permutation of "maxchar characters chosen from wlc with replacement". If there are none of the relevant character in wlc, it writes every possible permutation of that, probably consuming a lot of disk space if maxchar is the maximum supported, 15, and wlc is even as long as 8. (With 15 and 8, it uses 524288 GiB of disk. It'll be a while before we developers commonly see 500+TiB disks.)

    Personally, I detect the gentle aroma of rattus rattus here. I'm inclined to think that it's a joke function, because there's no way it does anything actually useful. (Notable: it does not generate a password.)

    Addendum 2024-07-10 09:03: Observation: if maxchar is less than 15, and wlc doesn't contain the pattern-making character, it repeats the ...

  • (nodebb)

    ... sequence until it has emitted len(wlc) ** (15 - maxchar) copies of the sequence.

  • Loren Pechtel (unregistered)

    Thought here--this is malicious, not nearly as incompetent as it appears.

    It's purpose is to generate a "random" password that's not even remotely random.

    Yes, there are bugs, but I don't think this is as deeply flawed as it's being made out to be.

  • (nodebb)

    I don't want to be mean, but that looks to my like the average Python code you sadly see these days. A lot of non-devs have started to use it even before the AI hype started popping up.

  • LZ79LRU (unregistered)

    This is one of the many reasons why I think substituting braces with whitespace was a mistake.

    Code form is something completely separate from code function and serves a completely different role. One is meant for the human reader and the other for the machine. By forcing them together all you are doing is forcing people to write code that are hard to read by humans.

  • FTB (unregistered) in reply to LZ79LRU
    Comment held for moderation.
  • Duke of New York (unregistered)
    Comment held for moderation.
  • Frank (unregistered)
    Comment held for moderation.
  • IPGuru (unregistered) in reply to LZ79LRU

    I have to disagree, not only does white space force the dev to write readable(with in limits) code, in this case it instantly shows the biggest error - too many levels of indentation. without even needing to analyse the code & the heart of the loop(s)

Leave a comment on “Classic WTF: Python Charmer”

Log In or post as a guest

Replying to comment #:

« Return to Article