#programming

1 messages ยท Page 26 of 1

dusty ore
#

why is the output always 0

#

Nah sorry my bad

#

the condition should be !=. not ==

brazen eagle
#

yup pretty much

#

you just set wtf to 0 otherwise

magic falcon
#

New c++ paradigm is to not use raw pointers, and encapsulate with an appropriate pointer object. Other than that, I second everything hydra recommended. String literals are always c constant strings that are immutable as well

brazen eagle
#

or did I get lost in 2015

magic falcon
#

auto_ptr was removed in C++17, for this use case, I'd suggest using a shared_ptr if passed in, or keeping the unique_ptr scope to the function itself.

#

Also, consider refactoring to separate stdin input from being read in the class functions, and passing inputs instead. Keeping business logic code separated from interface code has always made debugging much simpler in my experiences

brazen eagle
#

Ah right that was it

thorn moon
#

(You can, btw. As a bonus, you can technically override == and forget to also override != crylaugh)

brazen eagle
magic falcon
#

At least as much fun of Rule of 7 being partially implemented

brazen eagle
#

which one's that?

magic falcon
#

My bad, it's rule of 5

#

I mis-remembered

rigid tapir
#

I found the output of hashcat confusing since it was just hash:password with no usernames so I made a thing to reconstruct an /etc/passwd with the found passwords (don't tell me it already exists now). If there's any way of doing it better that would be nice to know ( converts $6$ hash to found passwords in any order in a list)

#cracked = [input("Enter path of hashcat output (format: $6$hash:password): ")]

file = ['~/test/unshadowed']
cracked = ['~/test/cracked']
count = 0
result = []
print("")
with open(file[0]) as x:
    lines = x.readlines()
    for line in lines:
        line = line.strip()
        splitline = line.split(':')
        if len(splitline[1]) <= 6:
            result += [':'.join(splitline),"\n"]
        else:
            with open(cracked[0]) as y:
                lines2 = y.readlines()
                for line2 in lines2:
                    line2 = line2.strip()
                    splitline2 = line2.split(':')
                    if splitline2[0] in splitline[1]:
                        count += 1
                        result += [':'.join(sub.replace(splitline[1], splitline2[1]) for sub in splitline),"\n"]
output = (''.join(result)).rstrip()
print(output + "\n")
print(count,"items replaced.",end='')

save = input(" Save passwordshadow.txt in this directory? (y/N): ")
if save == 'y':
    try:
        with open("passwordshadow.txt", "x") as f:
            f.write(output)
    except FileExistsError:
        save = input("File already exists, overwrite? (y/N): ")
        if save == 'y':
            with open("passwordshadow.txt", "w") as f:
                f.write(output)
else:
    pass```
onyx merlin
#

(don't tell me it already exists now).

#

So for hashcat, you can use --usernames to say the input file is username:hash format

#

Then with --show --username on the file it'll print it out nicely

#

I can't remember if it's username or usernames

rigid tapir
#

well i got the fun of coding some python anyway ๐Ÿ˜„ thanks @onyx merlin

wispy kestrelBOT
#

Gave +1 Rep to @onyx merlin

dim slate
#

Reccomendations for a HTML/css library for styling a multi page site I'm building?
Looking for ease of use and consistency basically.
My eye is on BootStrap5 presently.

humble sandal
#

tailwindcss

tulip sail
#

@restive fossilQuestion: Why?

restive fossil
#

project

#

thought it was cool

#

i know it sounds sus

#

its just a project

tulip sail
#

It definitely does sound sus ๐Ÿ˜†

#

Please don't ask here

restive fossil
#

yeah i know

#

oh so its not allowed?

#

ok

tulip sail
#

There's no way to know if you're using it illegally

restive fossil
#

ill delete

tulip sail
#

So, yeah -- under rule 9

restive fossil
#

ok, i understand๐Ÿ˜…

#

muir is there a place i can ask or is it completely forbidden?

onyx merlin
#

Reach 0xD, get OSCP/eCPPT, or complete Throwback then there's a channel for it

restive fossil
#

theres a channel that concerns malware?

hidden prawn
#

You will get access to exploit-and-mal-studies

restive fossil
#

oh thats sick

hidden prawn
#

So keep learning.

restive fossil
#

the only one that seems achievable right now is 0xD so imma get to doing rooms

bitter field
#

hey guys a little help with date formats

#

I have this date generated in my db 2021-05-29 20:47:41.966541

#

and this one received in my graphql 1622339261966

#

I cant decipher the second one

#

solved it was a milisecond time stamp

magic falcon
#

It's a std Unix timestamp

#

beat me to it

bitter field
#

hahahaha

#

whole 2 hours on this issue

#

๐Ÿ˜ข

#

wish I was joking

magic falcon
#

At least it was something this simple and not something that requires a lot of work to fix

bitter field
#

yea

#

still dont understand why graphql changes it

magic falcon
#

graphql is likely not changing it

bitter field
#

its iso on the db

#

2021-05-29 20:47:41.966541

magic falcon
#

the underlying structure is ms since jan 1 1970; your datetime obj is likely converting it to be human readable after the datetime is stored

bitter field
#

hmmm

#

welp its solved

magic falcon
#

that's a pretty common thing, in a lot of languages.

#

Folks want to argue with me about it, but from a machine perspective, what's more efficient to generate and store. wall time from the hardware in a raw byte format, or a complicated string with weird formatting

bitter field
#

yea I see why the unix on is better

#

just a plain string of numbers

magic falcon
#

what's the underlying db? postgres?

bitter field
#

yep

#

doing a fullstack project

magic falcon
#

are you using a timestamptz datatype for the column?

bitter field
#

I think so

#

Im using typeorm

#

using the createdatecolumn function

magic falcon
#

yeah, underlying data structure is microseconds

bitter field
#

you prob know more than me on this one kekw

frozen smelt
#

Hey yo, i am doing a source code (PHP) review and some stuff is not making sense so i wanted to ask about what does do for example :

#
preg_replace('/...(.)/', '$1', $$somevar)
#

what is the ...(.) thingy replacing

lilac holly
#

it looks like a regular expression, I'm not familiar with PHP (regex implementations can have some idiosyncrasies..) but usually

  • the dot . means one (any) character
  • parentheses denote a group you're interested in particular, to refer to later with the $1 you see as the second parameter
#

so it looks like it's particularly interested in the 4th character

#

the docs for preg_replace should help from there

#

and I hope I'm not leading you astray with this, someone who actually knows PHP please correct me if I'm wrong

frozen smelt
#

Thanks a lot @lilac holly i was trying to use regexeditor and stuff and i think it was leading to the same thing you were saying , so it does seems like its intrested in that 4 character

wispy kestrelBOT
#

Gave +1 Rep to @chrome crow

lilac holly
frozen smelt
#

Thanks i will check that website ut

warped axle
#

Hey i need some help with encryptions in cpp, i wanna use windows builtin but cant seem to find anything for cpp specifically, most of them are c# code so do i nees to learn c# or is there a way to do it with cpp

mortal flint
#

There should be a way to call a c# module from cpp code, but I don't remember it offhand, I haven't had to interop between those two languages in a long time.

warped axle
#

Im looking into it

magic falcon
warped axle
#

Hmm i've looked there but nothing yet tho

#

So they might have dumped it

magic falcon
#

The other alternatives for C++ seem to be crypto++ or openssl. If you aren't very familiar with using 3rd party libraries, you are going to have a struggle getting them to work.

warped axle
#

Yeah im gonna have so much pain with this

lilac holly
#

Guys

#

I need help

#

In a loop

#

I constantly have numbers that need to be added to a variable

#

That's fine, I did that

#

But

#

Once a certain command is detected

#

For example

#

"Adopt"

#

My code needs to break out and print text + variable after that

#

So my question is

#

The input will constantly be reading integers

#

But it must be able to read the command when inserted

#

How does that happen?

vernal vigil
#

if block?, like test if its an integer or no, if its not just print out what you want

hidden prawn
#

It's easier to provide source code and explain what you expect from it

magic falcon
#

Start writing unit tests

#

If a functionis longer than ~30 lines, break it into smaller smaller functions. This will help you compartmentalize your code so you aren't solving the entire problem all at once.

lilac holly
#

I had tasks

#

To do

#

But I did them, thanks anyways

#

They had certain requirements

#

It's just hard to explain without giving the official paper with the task, but well... Anyways

#

Thank you, wonderful people!

lilac holly
glass cape
#

i have done 65 % of course on solo learn for python should i do some leetcode problems or should i complete the course

vernal vigil
#

you can start with it if you're confident enough , upto you

lilac holly
#

Guys I'm new to programming.. I'm confused with python, java and JavaScript what should I learn first

#

I'm interested in contributing to open source too

true pumice
#

Python is much easier in my opinion, but it depends on what you want to contribute to.

#

I'd suggest that you learn programming principles and the basics of the language you want.

#

If you are not sure what you want, I would also suggest that you google what the best programming language is for the area you want to contribute to most.

magic falcon
#

Java as a language is more accessible, but there is also a higher learning curve to understand the environment to write hello world

lilac holly
#

Ohh okk

magic falcon
#

Really, it depends on what your goal is

#

The basic programming logic will be the same regardless of language

lilac holly
#

I'm just focused towards Google summer of code rn.. any help with that?

magic falcon
#

There are a lot of projects you can contribute to, in a variety of languages. Are you interested in how performant code is written, OS stuff, cloud application endpoints, and a lot of others. Pick a project that appeals to you, you'll get more out of it than just me giving you my opinion

wispy kestrelBOT
#

Gave +1 Rep to @magic falcon

west ether
#

hey guys i want to learn php , im done with basics but now i have no idea how to go from there . any advice ?

half osprey
lilac holly
#

guys i have a cpp code and there is an error saying " [Error] cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'size_t strlen(const char*)' "... anyone can help...sry new to discord idk how to i send my cpp code

solar hull
surreal bronze
solar hull
#

Ok?

warped axle
#

ok im strugling to work with cpp third party libraries, specifically openssl, you see i need nmake but that is not on my box, google and found out that i need windows sdk, downloaded that with vs but still nmake is not on the box, i really really need some help

#

also i tried conan, vcpkg but none of them ended up working properly

#

all gave the same error saying that it cant find an instance of visual studio

#

I am losing my mind so please help

whole haven
#

Does anyone know how to remove whitespaces when I try to include a php file. It's creating unnecessary whitespaces on webpage

magic falcon
warped axle
#

IDE

#

Sort of

#

Im using vim

#

And compiling with g++

red canopy
lilac holly
#

!crack c6920359ca4a08e3de98f3a3c0284e42e4a56dd0e474d949b44c78b6dc558eaafb1d2bb88f78d26d774b6e3ffc70be65

narrow terraceBOT
#
Cracks hashes via Search-That-Hash API

Searching c6920359ca4a08e3de98f3a3c0284e42e4a56dd0e474d949b44c78b6dc558eaafb1d2bb88f78d26d774b6e3ffc70be65 :sunglasses:

surreal bronze
#

broke

#

atm

#

will fix later

#

sorry

lilac holly
#

ahh sorry

#

also if i used this during a ctf is that cheating

onyx merlin
magic falcon
# warped axle Sort of

It's pretty clear you don't know the flags for whatever build system you are using. Please read the docs for g++ on including 3rd party libs, and the docs for all your dependencies. You may have better luck attempting your project in a more beginner friendly language, or simplifying your project's starting point

true pumice
warped axle
wispy kestrelBOT
#

Gave +1 Rep to @magic falcon

molten leaf
#

hi, if anyone knows html, js etc, i need some help pls peepoShy , so i have this code here, that creates a timer in js for an html website and its like a target practice website, so you need to click a taget that jumps to a random spot on the screen everytime you click it, so i crerated a function for that and used it with onclick="myfunction()", but im trying to check if the timer is at 0 seconds so i can disable the button but for some reason it never works, heres my code: ```function startTimer(duration, display) {
var timer = duration, minutes, seconds;
setInterval(function () {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);

    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;

    display.textContent = minutes + ":" + seconds;
    if (--timer < 0) {
        timer = 0;
    }
}, 1000);

}
var btn_test = document.getElementById('btn_test');

window.onload = function () {
var time = 2
display = document.querySelector('#TimerDisplay');
startTimer(time, display);
};

function Buttonrand(elem){
elem.style.position ='absolute';
elem.style.top = Math.floor(Math.random()*90+5)+'%';
elem.style.left = Math.floor(Math.random()*90+5)+'%';
}

btn_test.addEventListener('click', function(e)
{

Buttonrand(e.target);

});

var count = 0;
function myFunction() {
document.getElementById("text_forscore").innerHTML = "Score: " + count++;
}
/*
Here the time is supposed to be checked

if (time <= 0){
btn_test.disable =true;
}
*/```

#

pls help PeePoThink

#

i aleady tried to doif(time.value <= 0){btn_test.disable =true;} and any variation with "<", "==", etc. i cant figure it out

solar hull
molten leaf
wispy kestrelBOT
#

Gave +1 Rep to @solar hull

solar hull
undone kettle
#

heyy

#
struct dirent * dir = old_readdir(dirp);
if(dir && cwd != NULL) {
        if(strcmp(cwd, dirname(strdup(LD_PRELOAD))) + strcmp(dir->d_name,basename(LD_PRELOAD)) == 0){
          dir = old_readdir(dirp);
        }
        else if(strcmp(cwd, dirname(strdup(HIDDDEN_DIRECTORY))) + strcmp(dir->d_name,basename(HIDDDEN_DIRECTORY)) == 0){
          dir = old_readdir(dirp);
        }
}
return dir;
#

how could i simplify this so i dont repeat dir = old_readdir(dirp);in the if statements

mortal flint
#

if( (condition1) || (condition2) ){ doStuff(); }

undone kettle
#

ikk but the conditions are wayyy too big

#

it would look like trash

mortal flint
#

then do something like:
bool cond1 = your long expression here
bool cond2 = your long expression here
and then do what I said above, using cond1 and cond2

#

but name your variables something meaningful, that was just a shorthand.

brazen eagle
#

you can also break the || on two lines

#

compiler doesn't care about whitespace

solar echo
#

@undone kettle Hey, I know it's a bit late but you could also use a macro definition which in this case would be better than a variable since it doesn't take up any unwanted memory. For example :

#include <stdio.h>
#define TEST printf("Hello World\n");

int main()
{
    TEST
}

Will output :

Hello World

So you could assign your conditions to a macro statement and simplify the code to something like

#define CONDITION1 strcmp(cwd, dirname(strdup(LD_PRELOAD))) + strcmp(dir->d_name,basename(LD_PRELOAD)) == 0
#define CONDITION2 strcmp(cwd, dirname(strdup(HIDDDEN_DIRECTORY))) + strcmp(dir->d_name,basename(HIDDDEN_DIRECTORY)) == 0
#define STATEMENT dir = old_readdir(dirp);

struct dirent * dir = old_readdir(dirp);
if(dir && cwd != NULL) {
        if(CONDITION1){
          STATEMENT
        }
        else if(CONDITION2){
          STATMENT
        }
}
return dir;

Obviously for CONDITION2 you should try and keep the code snippet on the same line as the "initialisation" of the macro definition. Another thing to know about macro definitions is that you should always try and name them in uppercase letters. (see https://www.programiz.com/c-programming/c-preprocessor-macros).

One last thing (just a tip for programming in c and many other languages), instead of having == 0 at the end of your condition you could also wrap the statement in brackets and prepend an ! to the start of it... like so : ```c
!(strcmp(cwd, dirname(strdup(LD_PRELOAD))) + strcmp(dir->d_name,basename(LD_PRELOAD)))

when using an exclamation mark and brackets with a boolean value it reverses the value, so for example
`!(1)` (and anything more than 0) is the equivalent to `0` and `!(0)` is the equivalent to `1`.
solar hull
#

IMHO macros tend to make the code cluttered.

solar echo
#

just a suggestion

onyx merlin
solar echo
#

ยฏ_(ใƒ„)_/ยฏ

#

what can I say? I guess I just don't like taking up unnecessary memory

#

but whatever floats your boat

onyx merlin
#

Ah yes, sacrifice like 2 bools of memory and gain great readability especially in larger codebase

#

You get the memory back at the end of the function so eh.

solar echo
#

yeah but if it's the main function...

#

but I guess it doesn't matter too much, sacrificing 4 bytes of memory for readability is something that I can see happening

solar hull
#

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%

midnight lantern
#

Does anybody know the SQL here.??

I need help because I have to submit my assignment tomorrow ๐Ÿ˜ฉ๐Ÿ˜ซ

true pumice
#

I know enough to get by.

dry aspen
#

which IDE do you guys use for coding python?

#

editors/for dec

#

dev

hidden prawn
#

pycharm is nice

dry aspen
#

ye currently using that only

solar hull
#

pycharm / vs code

frozen smelt
#

Hi, a question in python i have timestamps like this : 23:22:00.123829 and 22:21:00.156789 how do i subtract them to get the duration

compact fern
#

You can take ticks of these values and substract them. After that you can convert substracted value to time.

hidden prawn
wispy kestrelBOT
#

Gave +1 Rep to @hidden prawn

frozen smelt
#

i willt ry both

frozen smelt
#

Hey, another question how do i delete like items from a list and then store it to the same list in python

#
id_of_email = np.delete(id_of_email, ids)
status_of_email = np.delete(status_of_email, ids)
time_of_email = np.delete(time_of_email, ids)
#

this something i was trying

#

but doesnt seem to work

magic falcon
#

What you are asking doesn't makes sense when compared to your code sample. Can you clarify what the list is and what the list consists of?

frozen smelt
magic falcon
#

Can you rewrite that as not a wall of text?

frozen smelt
magic falcon
#

Yeah.

frozen smelt
#

There is a list of ids of emails i am looping over to find the indexes of the items that have the same id

#

and then using those index i wanna remove them from the list

#

and want to store them to the same list

magic falcon
#

Break it down more. You aren't articulating well what you are still trying to find. Is the list only email IDs, or ist here other content and metadata in the list items as well?

true pumice
#

So you have a list of ids and you want to find which emails have the same* id and store them in a separate list?

frozen smelt
#

not store them but delete them from the list

#

and store it in the same list

magic falcon
#

So you want to remove items from the list while you are iterating over that list?

true pumice
#
temp = []
for id in list:
  if id in temp:
    id.pop()
  else:
    temp.append(id)

Like that?

#

It shouldn't work but it's a general idea

magic falcon
#

There are some other problems I'm getting at, Jabba ๐Ÿ™‚

frozen smelt
#

i will write some pseudo code

#
list = ["a","b","c","d","e"]
ids = [1,4]

# I wanna now remove these certain indexes [1,4] from the list
magic falcon
#

So again, are you trying to iterate over list and remove items from list at the same time?

true pumice
#

Oh, I see

frozen smelt
#

i iterated over a list got the ids i needed , and then before going to another iteration of the loop i wanna remove the ids and elements i already worked on

#

in that iteration i am doing an operation on those certain elements

magic falcon
#

Ok. So that's good; removing items from a list while you are iterating is bad. Don't do it.

true pumice
#

Like that?

magic falcon
#

My next question: Is there a standard list function as part of python that allows you to remove elements?

frozen smelt
# true pumice

yess the issue here becomes that the ids dont corelate then

magic falcon
#

Right. So why are you using delete()?

frozen smelt
true pumice
#

What do you mean by correlate? The IDs remove the wrong value?

frozen smelt
#

which is another libraru

magic falcon
#

So you aren't dealing with lists, you are dealing with numpy dataframes

true pumice
#

That's a problem with your other script then, it must be returning the wrong value

magic falcon
#

That makes everything you described very different

#

lists and numpy.df objects are very, very different.

frozen smelt
# true pumice

here as well it removes the 1 element but doesnt remove the 3 element d

frozen smelt
true pumice
#

Is it because lists start from 0 and you're starting from 1?

frozen smelt
#

soo i turned my list to numpy

frozen smelt
#

and in the final list it didnt pop out "d"

magic falcon
#

It's pretty clear you have a vague idea of what you are trying to do. Don't just blindly follow someone elses code, break down what you want to do before you start pounding away at the keyboard.

true pumice
#

It's straight forward

#

Simply

#

When you pop one vlaue out the list

#

the list becomes smaller

frozen smelt
magic falcon
#

Read the docs for numpy on dataframes and what delete() actually does.

#

You have a misunderstanding in your usage that you need to correct if you are going to use it.

true pumice
#
list = ['a', 'b', 'c']

# a = 0
# b = 1
# c = 2

One the first iteration, you would remove 'a'

list.pop(0)

Now the list is ['b', 'c']

b is now 0, and c is now 1.

Then when you're looping again, it's using the smaller list.

#

If that makes sense

frozen smelt
#

yess it does, i do understand thats how it works its just when for looping over the ids and deleting them we would have to decrease the ids everytime then

magic falcon
#

Jabba, you are making this too easy for Nick! Suffering is the root of acquiring knowledge

frozen smelt
#

Thanks guys i think its finee

#

i will figure it out , Thanks for your time and help

#

+rep @true pumice

wispy kestrelBOT
#

Gave +1 Rep to @true pumice

true pumice
#

You're a mentor, telling people to go research is the complete opposite of why we're here

magic falcon
#

I disagree. Mentorship is pointing people in the correct direction

#

Otherwise you are doing the work for them, which doesn't help them grow

onyx merlin
#

People have a responsibility to do their own research before asking.

frozen smelt
#

i mean not to be rude or dis regard your arguement a lot of people ask after getting stuck for a while

magic falcon
#

Handing people answers to really basic things instead of forcing them to work through the problem doesn't develop their problem solving skills at all

frozen smelt
#

i dont plop a question for every thing i see

#

but when it doesnt make sense

#

and solutions on the internet dont make sense

magic falcon
#

Yeah, I get you. Which is why I was asking questions to identify where your misunderstanding is

#

Then I can point you in the direction you need to go

#

The hardest part of learning and growing is knowing which direction to go in. There is a lot of bad info out there, and google doesn't always give useful results if the search term isn't exactly what you need

frozen smelt
magic falcon
#

He handed you the answer I was getting at - you were modifying the list and expecting the indices to be the same after removing an item.

#

My next set of questions would have revolved around step through debugging in your IDE or using pdb

frozen smelt
magic falcon
#

You really need to be better at articulating what the problem is, then. Because what I got from your initial ask was 'why isn't this working' not 'what's a useful approach to modify a list as i go over it'

frozen smelt
#

i was not asking for an answer more for how to approach the problem

#

i guess its my fault on how i formualted the question then so my bad

onyx merlin
#

-mute @severe shore 5m Don't be rude.

wispy kestrelBOT
#

๐Ÿ”‡ Muted T4TCH3R#6282 for 5 minutes

onyx merlin
#

Sorry, I was about to follow up my point

magic falcon
onyx merlin
frozen smelt
#

yeaah i was trying to explain how and why i used numpy there

#

as i tried a few other ways and they didnt tend to wokr

magic falcon
#

Oh, I get why you used numpy. One thing you need to remember when doing data analysis is that modifying the original isn't usually a good idea. Making copies of lists is really easy and fairly cheap to do - this solves the problem of modifying the list as you go

#

Unless your list is ridiculously huge, processing it using copies is usually a better route than trying to add or remove while you iterate over it

frozen smelt
#

yeah that was another approach i tried but it didnt work tried to store numpy into a new list and copy that new list to the old list

magic falcon
#

Additionally, if you already know what the value is you need to filter on, there isn't a need to make a second list of indices.

#

Why would you copy the new list to the old list?

#

The new list is just a subset of the old list

frozen smelt
#

i am not sure if thats goood

frozen smelt
magic falcon
#

Lessons hardest learned are best remembered.

frozen smelt
#

doesnt mean that everyone has to go through the same suffering the first guy who learned python did

#

again i dont want to be disrespectful as i appreciate your help

#

but it sounds like if i suffered in learning this i feel others should too

magic falcon
#

A large part of working in IT is developing problem solving ability. Creativity and flexibility are essential to that process; struggling with the problem seems to rewire the brain more effectively than just being told a solution.

frozen smelt
onyx merlin
#

why do you think people ask in the chat its usually when they have tried a few things and troubleshooted a lot I wish that was the case lol

hidden prawn
#

tbh many don't

frozen smelt
#

damn

#

i mean i tried a fair few solutions to solve mine and then when none worked i asked

bitter field
magic falcon
#

So I'll add this, then I need to get back to work: Being able to articulate and document a problem is at least as important as solving the problem is.

lilac holly
#

@lilac holly

lilac holly
sharp coral
#

hey y'all looking for advice on optimizing some code, this routine is the main algorithm for a program

my program reads a file byte-by-byte, if the int value of the current byte is not 0-2 then this algorithm get executed and returns a tuple which sums the int value of the supplied byte

this returned tuple is then split in two elsewhere in the program, each half written to a different file to be re-assembled at the user's leisure

problem is this program takes about 8 minutes to run on a 70KB file ๐Ÿ˜ญ

def theTupler(mainByte):
    factors = []
    goodPairs = [] 
    byteMe = mainByte[0]
    
    while byteMe != 0:
        byteMe -= 1
        factors.append(byteMe)

    raw_pairs = itertools.permutations(factors, 2)
 
    for tuple in raw_pairs:
        if (tuple[0] + tuple[1]) == (factors[0]+1):
            goodPairs.append(tuple)
    
    final = random.choice(goodPairs)
    return final
magic falcon
#

Have you run the profiler on your code?

#

The profiler will tell you exactly where the time is being spent; I have a suspicion on where it is, you'll kick yourself when you see it.

sharp coral
wispy kestrelBOT
#

Gave +1 Rep to @magic falcon

magic falcon
sharp coral
#

sure that sounds great!

vernal vigil
#

Don't think its a programming question, but anyways..

Why was stack chosen for growing downwards(downhill) and heap(uphill)?

is it just because to simplify indexing into the stack from a user program?

p.s. I am aware that stack going downhill is not a general thing, different processors have different ways.

mortal flint
#

There isn't really an up or down in computers/circuits, that's just the way we look at/interpret it, because it makes it easier to think about it or visualize it

vernal vigil
#

really because i read somewhere that it soley depends on the processor..?

mortal flint
#

Different processors do behave different ways, yes

magic falcon
#

Stack direction could also change given a combination of compiler and architecture as well - a compiled program may grow stack up on with compiler A and architecture X, but compiling with compiler B on architecture X may allocate differently and grow stack down.

vernal vigil
magic falcon
#

I'm not fully confident in my answer - take it with a grain of salt. My personal opinion is that it made stack and freestore easier to predict what we consider today consider low-memory systems. In all practical aspects, stack direction doesn't matter at all due to the random chunks that should be allocated at runtime for individual application usage

brazen eagle
#

counting down is somewhat more efficient, especially for checking if any space is left. As a test is always against zero, counting up would require a subtraction before the test

brazen eagle
#

the difference is marginal these days

#

though on smaller systems/ยตCs it might be relevent

lilac holly
#

@everyone
Hey guys is it possible to use tensor cores on nvidia gpu to crack password fast with cuda cores and tensor cores working to gather with help of AI algorithm run by tensor cores which will calculate hash of every next encrypted with specified hashing algorithm with some changes in tools like hash cat and john (because in gaming tensor cores are used to handel npcs and up scale the frame running on low resolution)and i think this is only possible on nvidia gpu because they have tensor in their gpu and programe called dlss and AMD GPU provied same but only on software side and their gpus don't have dedicated hardware in their for it

For example consider hashing algorithm in which encrypted version of abc something like this 2rd57hhs if the password is abc then tensor will find hash for a and then b and then c and send it to cuda for further processing

unreal tendon
#

dont use [everyone] please

lilac holly
#

Ok

unreal tendon
#

I am by no means an expert in cryptography , but the hash for abc is different than hash a + hash b + hash c for most hashing functions, also what would the AI do exactly ? I dont get it

lilac holly
#

Ok so consider a imaginary algorithm in which hash for abc is 2rd57hhs so ai will go to every known hashing and try to find with part of whole hash will try to match hash for a then and so on without any wordlist or dictionary while cdua in gpu will run normal CRACKING

onyx merlin
onyx merlin
#

"Every known hash" That's an insane amount of data, and you're describing a rainbow table.

unreal tendon
magic falcon
#

What you want to do isn't feasible. hash(A) + hash(B) != hash(A+B)

unreal tendon
lilac holly
#

Yes but on tensor core will spped up the process with help AI program for tensor cores corrently i m not able to explain but try to understand if you have graphics card like rtx 2060 having dedicated tensor cores for AI sittind idel when you are CRACKING on gpu the program will utilize them to crack hash faster

And i am not also crpto exprt i m just share thought of my mind

onyx merlin
#

There is no use for the AI

magic falcon
brazen eagle
#

don't think it's that feasible, besides, hashcat already abuses the GPU

onyx merlin
#

@lilac holly Unless you can describe why the tensor cores would be applicable, I don't think you're going to convince anyone that they're useful here.
You cannot just throw AI/ML at a problem and assume it will help.

brazen eagle
#

by definition a hash yields unpredictable results

#

a small change in input yields a big change in output

#

don't think ML'll be useful here beyond storing known plaintext:hash combinations...

onyx merlin
#

Why is ML applicable there? Searching sorted maps is fast

brazen eagle
#

might be able to speed up rainbow tables

#

I'm basically saying it's not useful in any case

#

but ML is the buzzword these days, gotta throw everything at it.

#

problem is that ML is good at finding trends/connections, but hashing by definition has no trends (or shouldn't in any case)

#

the point is that you can't tell what the input is for a given output

onyx merlin
#

Well, not without calculating it

brazen eagle
#

even then

onyx merlin
#

Expensive, time/computat ion wise

brazen eagle
#

given a hash, you can't find the plaintext without bruteforce

onyx merlin
#

Sorry, yes, misread that

brazen eagle
#

unless your algorithm is broken

#

but hey if someone can figure it out then go for it

unreal tendon
#

if somone could mathmatically break a modern hashing algorithm, to the point of instant reversablity

#

what are the wildest implications ?

magic falcon
#

You'd be able to reverse the hash. Making it not a hash, it would be an ecryption or encoding.

unreal tendon
magic falcon
#

You heard wrong.

#

Please provide sources, that contradicts everything I know about hashing.

unreal tendon
#

yes

#

ok so I checked , you are right, but I got confused between hashing and an article I read about what would happen if we found an instant way to solve sudoko

magic falcon
#

Domain-constraint solving is very very different than hashing.

onyx merlin
unreal tendon
magic falcon
onyx merlin
onyx merlin
unreal tendon
onyx merlin
#

I would but not at my PC

#

Anything I link would probably be academia so sometimes paywalled

lilac holly
#

Ok forget what i said before now question is can program like hash can utilize tensor cores on gpu to speed up the speed of CRACKING

#

Hashcat i mean

unreal tendon
onyx merlin
unreal tendon
#

@onyx merlin found the link to the video that talks about sudoko, , https://youtu.be/YX40hbAHx3s

Hackerdashery #2

Inspired by the Complexity Zoo wiki: https://complexityzoo.uwaterloo.ca/Complexity_Zoo

For more advanced reading, I highly recommend Scott Aaronson's blog, Shtetl-Optimized: http://www.scottaaronson.com/blog/


Retro-fabulous, cabinet-sized computers:

System/360: http://en.wikipedia.org/wiki/IBM_System/360

photo: "360...

โ–ถ Play video
onyx merlin
unreal tendon
#

woah

#

I read the first line

#

it would break auth

#

but also solve dna folding and path finding in the process,right ? (probably worng )

mortal flint
onyx merlin
#

One of my lecturers did it, with my final year project idea.
He didn't reply to my email asking how it could fit in to the project...

mortal flint
mortal flint
onyx merlin
mortal flint
#

๐Ÿ™„ ๐Ÿคฃ

#

And I'd be willing to bet that half of that is so that he can "advise" you on writing a paper to publish, for one more bullet point on his cv

onyx merlin
onyx merlin
#

And yeah, I didn't get a reply

#

Redacted something that might identify the guy

mortal flint
#

yeah, academia is a fairly broken system. At least in the US. I hear you folks have it a little better

brazen eagle
#

from what I understood about quantum computing is let's figure out a way to get a superposition of all possible results and collapse it onto the correct one

#

the rest is mostly magic

onyx merlin
mortal flint
#

Ever seen the movie "Sneakers" ? If half of what people say about quantum computing is true, it would break everything, and change all the rules

brazen eagle
#

it'll break RSA and DHE

onyx merlin
#

That's on my list.
I had to do a research project about quantum-safe crypto and the crypto break so I'd like to think I'm reasonably educated on it

brazen eagle
#

since those are based on prime factors

onyx merlin
#

The discrete logarithm problem is also affected by Shor's

brazen eagle
#

so most public key crypto then

onyx merlin
#

Grover's algorithm provides general speedups for hashing and sym crypto, but doesn't break break them

brazen eagle
#

symmetric crypto is a different beast

mortal flint
#

Have you heard the recent story about the "unhackable CPU" ?

onyx merlin
#

NSA's advice RE Sym crypto is just to go to AES-256 from 128

onyx merlin
brazen eagle
#

should be using AES-256 anyways

#

with a modern mode

onyx merlin
#

Currently, limited by the qbit count. There's a couple classes of quantum computers and we don't have anywhere near enough stable qubits in the right type.

brazen eagle
#

ie if I see you using AES in ECB mode you're getting your arse kicked from here to...somewhere far away

onyx merlin
#

Ok but it's neat!

brazen eagle
#

most quantum computing algos amount to fancy bruteforcing

onyx merlin
#

Grover's is the algo related to searches etc that weakens hashing and sym crypto

mortal flint
#

I'll have to take your word for that, I don't know quantum hardly at all

onyx merlin
#

I have a bunch of academic papers on it, but we all know how accessible they will be to most people here...

brazen eagle
#

try all the possibilities and measure the one that fits

mortal flint
#

but even if it's brute forcing, if it can do it at many orders of magnitudes faster than current, it suddenly makes impossible things feasible

brazen eagle
#

in very vulgarized terms

#

it bruteforces in O(1) time basically

#

If I understood correctly

mortal flint
#

so yeah.... that's a big deal

#

that changes everything

brazen eagle
#

it does

#

which is why you have to rethink encryption

onyx merlin
#

I recommend leaving the rethinking of encryption to the crypto people

brazen eagle
#

yes

#

still O(n) space though, probably

onyx merlin
#

We have the standards really, I think we're in the final rounds of some of the competitions

mortal flint
#

the "royal you"

brazen eagle
#

that said, for now, use proper Key-derivation functions, and AES-256 in a sane mode.

#

and DHE or some other public key crypto to share the key

onyx merlin
#

That reminds me, I want to write a challenge response protocol

#

Another thing for my list then

brazen eagle
#

most of them use RSA or the like

#

encrypt a nonce, send it as the challenge, response should be the same nonce encrypted using the challenger's public key

#

for example

#

(this would probably be a bad method tbf)

#

look up Webauthn though, it's pretty neat

onyx merlin
#

Whomever coined the word "nonce" in cryptography was certainly not british.

onyx merlin
brazen eagle
#

look up Kerberos then

sharp coral
#

@magic falcon hey FWIW I managed to trim down that function I was working on the other day down to a quarter of the size and thanks to pytest actually had improvement I could measure - still slow as hell but does exactly what I want

wispy kestrelBOT
#

Gave +1 Rep to @magic falcon

sharp coral
#

now to tackle multi-threading program design next

magic falcon
brazen eagle
#

look up concurrent.futures

sharp coral
sharp coral
magic falcon
brazen eagle
#

It seemed to be the easiest threading bit to me in python3

#

It combines well with tqdm if you need progress bars

magic falcon
#

I thought async was the easiest, but it doesn't get around the GIL. multiprocessing does, and it looks like concurrent.futures is tightly coupled to multiprocessing

brazen eagle
#

Or is it tdqm

#

Concurrent.futures simplifies the syntax at the very least

#

I can grab some examples in a bit if needs be

sharp coral
#

if have you have em please do, ill throw them in my notes - either way I know where to look now ๐Ÿ™‚

brazen eagle
#
class PortScanner:
    def scan_port(self, server_url, ip, port):
        try:
            r = requests.get(url=f"{server_url}Images/Remote?imageUrl=http://{ip}:{port}", timeout=1)
        except requests.exceptions.Timeout as e:
            return;

        if r.status_code < 400:
            print(f"{ip} : {port} {colours.green}OPEN{colours.end}")

    def scan(self, server_url, ip, ports):
        ip_port_tuples = ((server_url, ip, port) for port in ports)
        with concurrent.futures.ThreadPoolExecutor(max_workers=32) as executor:
            executor.map(lambda p: self.scan_port(*p), ip_port_tuples)

Here's a basic port scanner

#

that I used for my jellyfin attack

sharp coral
#

oh wow thats a lot more readable than what I was looking at lol

brazen eagle
#

max_workers is the number of threads, basically

#

executor.map takes in a function

#

I use a lambda here because my function has multiple params

#

but if I had no params, then I can just use the function reference

#

recommend looking at the documentation though

#
import base64
import bcrypt
import sys
import concurrent.futures
from tqdm import tqdm

salt = b'$2b$12$SVInH5XmuS3C7eQkmqa6UOM6sDIuumJPrvuiTr.Lbz3GCcUqdf.z6'

def testPasswd(password):
    bpass = password.encode('ascii')
    passed= str(base64.b64encode(bpass))
    return bcrypt.checkpw(passed.encode(), salt)

def genPasswd(password):
    saltySalt = b'$2b$12$SVInH5XmuS3C7eQkmqa6UO'
    bpass = password.encode('ascii')
    passed = str(base64.b64encode(bpass))
    crypted = bcrypt.hashpw(passed.encode(), saltySalt)
    return crypted == salt

with open(sys.argv[1]) as f:
    passwords = f.readlines()
    maxLines = len(passwords)
    print(f'{maxLines} passwords to test')
    with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
        for pwd, res in tqdm(zip(passwords, executor.map(genPasswd, passwords, chunksize=10000)), total=maxLines):
            if res:
                print(f'Found match: {pwd}')
#

here's a bit that was trying to crack a bcrypt password for a room

#

sorry about the bad code

sharp coral
#

oh you haven't taken a look at github then don't worry about bad code lmao

#

this is super helpful though, i guess my biggest hurdle is just kinda wrapping my head around designing functions that work with multiple threads, I just have to make sure things are put in order in my case

magic falcon
#

I don't remember all the details offhand, but multiprocessing should be better for data in memory, and async should be better for I/O bound tasks. @brazen eagle probably has better insight here than I do

brazen eagle
#

I don't know python THAT well

#

I just use whatever's easier to code ๐Ÿ˜„

#

but I'd probably generate benchmarks if I really wanted to try optimizing

#

for multithreaded functions, you want to remain as stateless as possible.. good advice for any function, really

#

avoid side effects and everything should be fine

#

if you need to modify state then you'll have to look into mutexes or semaphores, and those are a pain in the arse

mortal flint
#

Do any of you have a python profiler you really like?

magic falcon
#

For most analysis, i use cProfile. I think I've only used profile once, and it was significantly slower

mortal flint
#

cool, thanks. I haven't worked with it before but can look into it

fair zephyr
#

i made something with multiprocessing and logging, nothing too fancy

#
#!/usr/bin/env/python3
import multiprocessing,requests,logging,time,queue
from multiprocessing import Pool,Process
class Request(object):
    def __init__(self,url):
        self.url = url
    def main(self):
        arr = []
        global wordl 
        wordl = open('/usr/share/wordlists/dirb/common.txt','r')
        readw  = wordl.readlines()
        for i in readw:
            r = requests.get(self.url + '/' + i)
            global positive_req 
            positive_req = r.status_code == 200 or r.status_code < 400
            arr.append(positive_req)
            if r.status_code == 200 or r.status_code < 400:
                print(f'[{r.status_code}]Request->{self.url}/{i}')
            else:
                print(f'[{r.status_code}]Request->{self.url}/{i}')
    def output(self):
     openwl = open('/usr/share/wordlists/dirb/common.txt','r')
     print('Saving positive response to a txt file(If any).')
     readwl = openwl.readlines()
     for i in readwl:
         r2 = requests.get(self.url + '/' + i)
         positive = r2.status_code == 200
         with open('dirs.txt','w') as saved_file:
          for i in readwl:
           if r2.status_code == 200:
             saved_file.write('/' + str(i)) 
          else:
              pass
if __name__ == '__main__':
    Req = Request('https://google.com')
    process = Process(target=Req.main)
    process_output = Process(target=Req.output)
    q = queue.Queue()
    t = time.time()
    try:
        logging.basicConfig(format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S')
        logging.warning('Request started.')
        for i in range(10):
            process.start()
            process.join()
            process_output.start()
            process_output.join()
            print("Done in: {}".format(time.time()-t) + 's')
    except Exception:
        logging.error('Status Finished.')
                                          
slate hatch
#

help i am trying to code a cooler command prompt and it wont open it just immediatly crashes

#

@echo off
chcp 65001 >nul
cls
:top
color 2
title Cool Command prompt
echo Welcome to the Cooler Command Prompt
echo Type 'Help' For Commands!
color 7
echo Microsoft Widnows [Version 10.0.19042.985]
echo (c) Microsoft Corportation. All rights reserved.
echo.
echo C:\WINDOWS\system32>
set /p main=C:\WINDOWS\system32>

if %main% == help goto help

:help
echo Commands

#

pls help

#

i dont know whats wrong it in batch btw

restive fossil
#

is it possible to make a python program that runs as a background process: so to elaborate how can i make program, that when clicked, doesnt show it is running but once you open task manager, you see the program running?

true pumice
#

Given your previous comments, I am considering asking you to ask elsewhere.

void falcon
#

I even refer the above link and installed ssh but it did not work I was not able to ssh in to my system. As ubuntu come with pre installed openssh . I removed it by using this command sudo apt-get remove --purge openssh-client and this command also sudo apt-get remove --purge openssh-server and again tried installing using portable openssh but it gave the error ssh.service not find. Can anyone help me with this

halcyon sandal
# restive fossil is it possible to make a python program that runs as a background process: so to...

It sounds like you want to "daemonize" the process: https://en.wikipedia.org/wiki/Daemon_(computing) I suggest you research on "how to create a daemon process in Python" - it really depends if you want to do this under Unix or Windows, whether you want to use a library etc.

In multitasking computer operating systems, a daemon ( or ) is a computer program that runs as a background process, rather than being under the direct control of an interactive user. Traditionally, the process names of a daemon end with the letter d, for clarification that the process is in fact a daemon, and for differentiation between a daemo...

restive fossil
halcyon sandal
#

@restive fossil I haven't done this since I have used Python mostly under Linux, but it seems to do the trick under Windows ๐Ÿ™‚ A daemon might be too complicated for your case ๐Ÿ™‚

gentle ginkgo
gray ledge
#

is anybody familiar with python websockets?

remote echo
#

Someone will help

glass cape
normal sable
#

could someone please help me and explain a how an sqli scanner I found actually works? the program is only 100 lines long but I can't understand it very well and it would really help if someone could explain it for me as I need to be able to recreate for a project I'm working on. Thank you for any help

#

Or just how to generate and detect sqlis in python would be great ๐Ÿ˜…

fathom bramble
#

can anyone recommend a good resource for learning powershell?

vernal vigil
wispy kestrelBOT
#

Gave +1 Rep to @vernal vigil

wispy kestrelBOT
#

Gave +1 Rep to @glass cape

ebon dawn
#

i need to do the following

  1. Write a command (pipeline) that would summarize the number of daily logins of each user.
  2. Use the above to write a script, which would report that numbers -- only the nonzero ones -- to a log file.
  3. Prepare a crontab entry so that the script would be run once a day.
    this is the first script
#

for the second task i need to check if the last password change happened more than 90 days ago and if so require the user to change the password

#

this is unix bash

#

btw

#

sorry, got rerouted from general

glass cape
#

what have you tried till now

ebon dawn
#

learning unix

sharp coral
#

start with this

  1. Write a command (pipeline) that would summarize the number of daily logins of each user.
    there are some log files you can use for this purpose
glass cape
#

do you want that some one should right a code for you ??

ebon dawn
#

no, i just dont know what to look for

#

but yeah of course i would want to do nothing who wouldnt, but that's not what im asking

ebon dawn
#

but if the file already exists there is no need to do so

#

which file is it tho

#

somethere in the /etc id guess

sharp coral
#

nope - linux provides a load of log files you can use here - i'd probably use /var/log/auth.log - now I leave up to you how you should parse that

#

you can read the log file with paged output with less -S, skim around the file and look for what a successful login looks like, then you'll need to parse the date and make sure its from today

ebon dawn
#

so i need to look data parsing for linux

sharp coral
#

you shouldn't need anything more than cut, tr, awk, and grep - all of which are native linux tools

ebon dawn
#

btw man, my bash tells me there is no such file or directory

#

yeah ik grep

#

there was a command i found online

#

hol on

#

grep LOGIN /var/log/messages |grep username | wc -l

sharp coral
#

i've never seen or heard of the messages log - that might be a 3rd party application

ebon dawn
#

but this doesnt use the dir you sent

ebon dawn
sharp coral
#

sudo find / -type f -name "auth.log" 2>/dev/null

#

try that

magic falcon
#

Where the auth logs are stored also varies a bit from distro to distro. Ie, Ubuntu stores those logs in a different file than in CentOS

sharp coral
#

ah okay gotcha - I just found this bit
makes sense as Im usually on ubuntu

magic falcon
#

Yep

sharp coral
magic falcon
#

This also easily an easily searched for problem ๐Ÿ™‚

ebon dawn
#

lol it doesnt exist either

magic falcon
#

What distro are you using?

ebon dawn
#

how do i check?

#

bash --version

#

?

magic falcon
#

What distro of linux

ebon dawn
#

im not using linux as an os

#

im using ubuntu terminal

magic falcon
#

So you are using Ubuntu as a terminal. But you aren't using Ubuntu as an OS?

sharp coral
#

are you using Windows Subsystem for Linux?

ebon dawn
#

with a linux stuff for windows

#

yes

#

subsystem

tulip ibex
#

wsl yea

sharp coral
#

ah

ebon dawn
#

is it shit?

magic falcon
#

Oh, then I can't help you. WSL and WSL2 always break for me, so I don't touch them.

tulip ibex
#

wont say that

ebon dawn
#

i just cant connect to a remote host because the server is down

#

ssh is not working

tulip ibex
#

wsl is sometimes good

#

when am too lazy to boot vms kek

sharp coral
#

well you'd need to be parsing Windows logs in this case - I would install Sysmon - create a powershell script to parse that - use Windows Task Scheduler to schedule execution of the powershell script

magic falcon
#

networking in WSL is also broken - if you are on WSL2, I would expect SSH to work, but not with WSL1

ebon dawn
#

thing is i used putty for connecting to remote host

#

which works fine

#

but it doesnt work anymore

#

i changed ports

#

but still

ebon dawn
#

but i guess if i got nothing else to do

sharp coral
#

its pretty easy tbh, if you like python they also have a library for parsing EVTX

ebon dawn
#

i dont

#

lmao

sharp coral
#

more things to learn ๐Ÿ˜„

ebon dawn
#

maybe in the future

#

but now i need to do this unix shit

#

alright are there some free hosts

#

servers

#

that run unix

sharp coral
#

do you not have the resources to run a virtual machine?

ebon dawn
#

resources as in time or computational power

#

or the very will to do so

#

depends on all three

sharp coral
#

all of the above

ebon dawn
#

well

#

id say yes

#

which vm should i install

sharp coral
#

big fan of ubuntu LTS but Mint or PopOs are good choices

ebon dawn
#

price list?

sharp coral
#

either way, just choose one, live in it and stick with it

ebon dawn
#

i need the one that's a bit

#

free

sharp coral
#

free forever!

ebon dawn
#

good

#

dude are you available for a call im with my friend and he keeps asking me

#

or maybe create a groupchat

#

if your're fine with that

#

im just tired of decrypting everything yousay to him

sharp coral
#

unfortunately not right now - if you have questions ask them here for the benefit of everyone else ๐Ÿ™‚

ebon dawn
#

aight man either way, thank a lot for your input

#

or woman

#

or maybe someone else

#

we're inclusive

sharp coral
#

just using gender neutral terms is always a good rule of thumb - and np feel free to ping if you have further questions

ebon dawn
#

have a blessed whatever the sun's position in degrees is relative to you

ebon dawn
#

ubuntu lts weighs over 2gigs and with my internet speed ill need at least 3 hours to download it

#

guys

#

any other suggestions?

tulip ibex
#

let is download at night

ebon dawn
#

i need to finish it asap

#

no deadline i just have shit to do tomorrow

#

but i guess there is nothing else to be done?

#

any other variants?

#

i can do it next week tho

magic falcon
#

Any linux iso is going to be at least 3GB to download - anything smaller than that will be a netinstaller version, and it sounds like that is going to also not work for you.

ebon dawn
#

๐Ÿ˜”

vernal vigil
#

Lbuntu

#

Maybe

#

Or Arch..?

ebon dawn
#

those are?

#

VMs?

vernal vigil
#

You can install them on a vm

#

Just like ubuntu.

void falcon
#

Can anyone suggest how to modify ssh service so that it can store password in Auth.log file in Ubuntu system.

magic falcon
#

That violates every security best practice I can think of. Why are you trying to modify the service?

cursive zephyr
#

Can someone tell me why this function returns undefined function checkCreds(username,password){ fs.readFile(`U_Conf/${username}/creds.txt`, (err,data)=>{ let creds = JSON.parse(data); if(username in creds && password === creds[username]){ console.log('Connection Success'); return true; } else{ return false; } }); }

solar hull
#

Because youโ€™re not returning the result of fs.readFile

solar hull
solar hull
#

Looks like readFile doesnโ€™t return anything. So youโ€™ll need to handle the values some other way than by trying to return them from the callback

lilac holly
#

Can someone please help me?
I'm learning Java I am not able to understand what

Date now = new Date();

does

onyx merlin
solar hull
solar hull
#

Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

ebon dawn
#

hello lads

#

here i go again with unix

#

i need a file location that would help me get info on password changes

#

i need to write a command that would check if last change of password occured > 90 days ago

#

okay nevermind i found the chage

void falcon
lunar dune
#

hi anyone here good with shell scripting ?

magic falcon
#

What's your question?

maiden karma
#

Hey does any body know how to create a js script that stores the user input and create a box with all of that information?

formal kettle
#

ehhhh, node with db

broken shuttle
magic falcon
#

Brent, can you reword your question? I'm not exactly sure what you're asking.

solar echo
#

@magic falcon I think, he may be trying to ask "Why do you do this?" or "What is there to do in this course?"

true pumice
#

Always best not to presume ๐Ÿ˜‰

thick marsh
#

if i have an executable that runs shellcode that is basically a meterpreter, if the user has antivirus software, what could i add to the executable to give it more power.

mortal flint
#

More power? @digital dove

onyx merlin
#

Good luck evading AV with a meterpreter lol

thick marsh
onyx merlin
#

What are you attacking?

thick marsh
#

windows machine

onyx merlin
#

What Windows machine?

thick marsh
#

its a personal project im not going after any ctf rn, I wanted to learn about how stuff like that worked

#

i didnt really know about anything else then meterpreters so thats cool

mortal flint
#

I know a bit about writing malware, but I probably shouldn't go into that

thick marsh
#

well i'd love to learn

#

only thing i know how to do for now is running shellcode with a c++ program nothing crazy

onyx merlin
#

Ok. We don't discuss that here.

#

If you reach 0xD, get a relevant pentest cert like eCPPT or OSCP, or complete throwback, then there's a channel for it

thick marsh
#

awwwww

onyx merlin
#

I'm sure you understand why

thick marsh
#

yeah ik

mortal flint
#

Consider that motivation to be more active here ๐Ÿ™‚

thick marsh
#

yeah true

#

well i'll take the fact that theres more than just meterpreter as a hint

mortal flint
#

There are some interesting books that talk about concepts of some big hacks, but not really technical details. That might be an interesting read for you while you're building up skill and points here

thick marsh
#

will do

mortal flint
#

There's also a malware analysis path/module here, but I haven't done it myself yet

thick marsh
#

ill look at alternatives to meterpreter to find a better/ more powerful one, rn im thinking of maybe modifying the program to do some stuff like maybe changing some or adding stuff

#

idk

solar echo
tulip sail
#

The only thing you'll get better than that are C2 launchers. Have a look into PS Empire and Covenant for the big, free ones. Cobalt Strike is objectively better, but costs an absolute fortune

#

There are hundreds more of them too, of varying degrees of effectiveness

#

Have a look into Wreath for more info

onyx merlin
#

I'm pretty sure they're just trying to evade AV

thick marsh
wispy kestrelBOT
#

Gave +1 Rep to @tulip sail

thick marsh
onyx merlin
#

Yes.

#

That's AV evasion.

thick marsh
#

yeah

thick marsh
onyx merlin
thick marsh
#

oh right

tulip sail
#

Not directly, but they're easy to edit yourself ๐Ÿคทโ€โ™‚๏ธ
Also, yeah ^^

thick marsh
#

Thank you again

onyx merlin
#

AV evasion is quite an advanced topic.

thick marsh
#

i see

tulip sail
#

It's also a huge pain in the ass

thick marsh
#

it sounds fun so im up for the challenge

onyx merlin
#

Get to 0xD and then you can discuss it in the specific channels here ๐Ÿ˜‰

thick marsh
#

how can i speedrun it

onyx merlin
#

Do like, Advent of Cyber

thick marsh
#

alright

restive fossil
onyx merlin
#

Not really

cursive orchid
#

any css frameworks that have components sort of like this?

#

both the navbar styling and those filter type buttons

bitter field
#

Choc ui and chakra templates has a lot of good navbars/buttons

formal kettle
#

Breadcrumbs? And ul with flexbox maybe, not sure bootstrap can do that,

cursive orchid
bitter field
#

anyways you could prob find good stuff on bootstrap, though not my favorite styles

#

css frameworks are becoming big, like tailwind now has headless ui which is so good

cursive orchid
#

but i will deffo be using that in my react projects

#

i just stole some free bulma template hehe

restive fossil
#

can someone spoonfeed me the code for wgetting printspoofer in python? (windows btw)

#

cant get it working

true pumice
#

Do you want a compiled copy or learn how to compile it yourself?

#

Or are you looking to get it onto a machine?

restive fossil
#

compiled

#

cant wget it from github ยฏ_(ใƒ„)_/ยฏ

true pumice
#

You would have to download it, compile it and then transfer it across

#

If you're using a simple python script to get it across, you would use something like

restive fossil
true pumice
#

Actually I'm not sure if this would work but:

import os
import sys

url = sys.argv[0]

os.system(f"curl {url} -o printspoofer.exe")
#

But you might as well just type curl url -o printspoofer.exe

#

Then again, I don't know if curling it onto a machine would work

restive fossil
#

i am so stupid

#

jabba thanks for saving the day once again

loud bone
#

How can I create a similar tool like nmap, dirbuster, etc (but less functionality to begin with) using python?

onyx merlin
#

Have you done some research into it first? Googling terms like "python port scanner" and "python web directory brute force"

mortal flint
#

Break down the problem. What will you need to do? Parse command line args? (search for how to do that) Loop/iterate through something? (more searching) Call a URL/open a port/etc? (more searching)

#

start with the big concepts, then break them down into smaller and smaller tasks until you get to a task that is small enough you can solve, and go from there

#

maybe start by hard-coding the program to scan a single IP, or a single port, or something like that.

loud bone
#

Okay, I did some research. The thing is after creating a script using python, have to run like python3 <script_name.py> but I want like just run <scirptname> and that will run it. (just like any tool in linux command line)

#

Probably will do the arguments or flags after that

stoic badger
#

That bit of the program is probably the least important if you don't have the actual substance of the thing done

#

Focus on getting something usable before worrying about the QoL or the cosmetics imo

loud bone
#

I mean, I just wanted to see if that is possible with python if not then will try to do the actual thing in different lang

mortal flint
#

there are a few different ways to compile python. I haven't worked with any in a couple years, but they were all kindof a pain to work with

#

but I'll second what @stoic badger said- focus on getting it working, even just "proof of concept" style first, then you can look into distribution/packaging/etc.

#

another option, as a short-term fix, is to make an alias or a .sh file

#

so you can type "myCoolProgram -my arguments" and that is aliased to run "python ....." or some shell script.

stoic badger
#

agile development

#

I mean, this kind of applies with all workflows, but still

warped axle
#

hey can someone explain this regex to me? q(?=[te][st])[co][de]

#

i am very confused

restive fossil
#

so this runs as admin btw, when i run it this is what shows up

#

but when i run that exact command in cmd with admin privs this is what shows up

#

sooo, since im running the py file as admin, shouldnt i get the exact result with both?

lilac holly
#

Hi guys. What language would you learn for malware development in Windows? C, C++ or C#?? Thanks

onyx merlin
#

C#

#

For the pure reason of the Windows APIs

magic falcon
restive fossil
# onyx merlin C#

really? i would've thought c was the best for malware since most malware makers use C as their preferred language

hollow gale
#

C++ FTW

restive fossil
magic falcon
restive fossil
# restive fossil

but juun when i run printspoofer as admin in cmd i get nt authority normally, shouldn't that mean that running that file as admin should give me nt authority?

magic falcon
#

are you running it directly as the admin user, or as the regular user with elevated privs?

#

Caveat: I'm not super up to date on non-domain managed privs, so I could be sending you down a wrong path

#

Windows also does weird stuff with file and user contexts; i'm much more familiar with Linux contexts.

restive fossil
#

look heres the interesting thing: i go into cmd with normal privs, i dont have selimpersonate privs, however, i go into cmd as admin, i do, so when i run printspoofer as admin, it works.

magic falcon
#

That sounds like how it should be

restive fossil
#

oh

magic falcon
#

You may want to wait for a better windows mgmt SME to answer - that sounds like intended behavior to me

restive fossil
#

ight

magic falcon
#

I understand how RBAC should work, and that sounds like it's operating correctly. AD may be doing fucked up stuff

sharp coral
restive fossil
#

ok im a beginner to c and i dont really understand void (void main())

#

what difference does it make to int main()

magic falcon
#

Depends on compiler. void indicates that no return is expected, in older compilers it was required that main() return an int to use as an error code.

restive fossil
#

oo ok

magic falcon
#

It's a simliar thing with main( int argc, char* argv) sometimes being omitted

warped axle
#

since it basically follows the patern in the text

sharp coral
#

Im not sure what your use case or example is - but I would just think of the lookahead as a conditional statement, i.e. "Match this string if it begins with x but do not capture x in the final output"

restive fossil
#

is & gt in C "greater than" and & lt is "lower than"?

magic falcon
#

Are you asking about a specific operator? & has a very specific meaning that doesn't match what your question is

restive fossil
magic falcon
restive fossil
#

ok

magic falcon
#

That's not the full snippet. Where are the variables being defined?

#

Where are you getting this code from?

restive fossil
magic falcon
#

ok, what's happening is wherever you are getting this from is screwing up the code

#

&gt; looks like it's some kind of code formatting to display the >= operator

#

or rather just >

#

same thing with the &amp; bits

restive fossil
#

yea i guessed so, dont know why w3schools making things more complicated (โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

magic falcon
#

post the link please

#

nm, found it

#

You'll commonly see stuff like this when the web server is doing replacement of characters and messes it up. &gt and &amp are the proper symbol codes for HTML; however, their rendering engine is breaking the symbol code up into multiple words.

onyx merlin
little jewel
#

Hi

warped axle
#

more regex question (?1) this recurses a subpatern / calls a numbered group, question is what are either of those? google didnt help too much

restive fossil
#
#include <stdlib.h>

int main()
{
    int a,b,c;
    printf("Please Enter Two Numbers \n");
    scanf("%d %d", &a, &b);
    c = a + b;
    printf("The result of the addition of both the numbers is %d \n", c);
    if(c != 11)
    {
        printf("please kill me");
    }
    while (100 > c)
    {
        printf("%d \n", c);
        c++;
        switch(c)
        {
        case 50:
            
        case
        }
    }

    return 0;
}```
#

heres the code

#

C btw

#

so in the case 50, i want to make it not print 50

#

how do i dat

mortal flint
#

your print statement would need to move, or you'd need to surround it with an if block

safe brook
#

hey guys do you have any python library learning suggestions in order to increase my ethical hacking knowledge

heavy rampart
restive fossil
#

yeah i was actually wondering if continue would do the trick

#

thx man

#

+rep @heavy rampart

wispy kestrelBOT
#

Gave +1 Rep to @heavy rampart

brazen eagle
#

you should increment at the end of a while block. does C even have a switch statement?

#

apparently it does, TIL...

#

ARG FRACK JAVA! bloody dependency pulling a java 11 lib instead of java 8

restive fossil
#

y does it say the address of *pntr in 14??? shouldn't it be 61fe14?

hollow tangle
restive fossil
#

oh cool, y does it have to be pntr only?

hollow tangle
#

With pointer types the * means to dereference the pointer and access the value so just putting pntr without the * means don't deref and print the actual value of the pointer

restive fossil
#

ohhhhhhhh

#

got it

#

damn

#

+rep @hollow tangle

wispy kestrelBOT
#

Gave +1 Rep to @hollow tangle

restive fossil
#

there we go

restive fossil
#
{
  FILE * fileName;
  char ch;
  fileName = fopen("anything.txt","wt");
  for (ch = 'D' ; ch <= 'S' ; ch++) {
    putc (ch , fileName);
    }
  fclose (fileName);
  return 0;
}```
#

wat is going on here

#

main thing i dont get is the ch <= 's'

#

how can a character be larger than another character

magic falcon
#

Characters are a set that is well-ordered.

#

The text character is represented by a symbol, what is the underlying representation in memory?

turbid fable
#

Hello, is there a C programmer ready to help me ? ๐Ÿ™‚

magic falcon
#

What's up? Feel free to drop your question here

mortal flint
brazen eagle
wicked wagon
west locust
#

does anyone know anything about this "Using EoL Python Versions on Kali" i m getting errors

rancid sigil
wicked wagon
#

@rancid sigil Ok understood

#

when attacker checks logs on his sever he gets the api key's of users who visited

#

his site and from there visited the vulnerable website

#

am i correct ??

sour apex
#

is there anyway to prioritise addition over multiplication?

#

without adding paranthesis

#

or is there a way to automatically add paranthesis for two values with a '+' b/w them

mortal flint
#

Nope. Not unless you overload the operator, which could get you tarred and feathered by the other people on the team.

mortal flint
#

what language are you using?

sour apex
mortal flint
#

just add the ( ) and call it a day ๐Ÿ™‚

magic falcon
mortal flint
magic falcon
#

i wasn't scrolling

#

i was reading top-down, like a good programmer who reads docs ๐Ÿ™‚

mortal flint
#

what are docs? ๐Ÿค” ๐Ÿ˜•

#

oh, that's the part that the unicorn team is supposed to do. Yeah, that's still backlogged

#

tried and failed to find a clip from Volcano of Don Cheadle saying "you gotta be fast". sadcooctus

mortal flint
#

That looks like something from hoonigan

mortal flint
#

I've ridden in a smartcar. I'd be terrified to be in one that did that

magic falcon
#

You ride racing motorcycles, how is a smart car outfitted with a hayabusa engine more scary

mortal flint
#

That's precisely the right question ๐Ÿ™‚

#

at least on a bike if it wrecks, I have my airbag suit and can slide. In that smartcar, it'd crush like a soda can. And once those front wheels lift, you have virtually no control over anything. On a bike, you have lots of control over braking/steering/lean/etc.

magic falcon
#

you can't tell me it wouldn't be a blast to go full gymkata in that hyped smart car though

mortal flint
#

gimme a roll cage and a 5 point harness and a neck brace, and I'd do it

#

trust me, being in a vehicle that rolls, without a cage, without a helmet, without gear, that aint no fun. Especially when there are heavy and sharp things bouncing/flying around too

magic falcon
#

I always thought driving a reliant could be fun

mortal flint
#

that 3-wheel thing? that's gotta be massively unstable

dire vortex
#

heyo, anyone here who's dabbled in bash a fair bit?

#

I've got a script, that backgrounds a process, and I'm trying to detach the child process from the parent one - so that killing the child won't also end the parent, but disown -a doesn't seem to do it for me

#

I can provide screenshots etc. if I didn't explain the issue clearly enough

#

disown seems to work absolutely fine testing in my bash terminal, but when it comes to a script executing it, no luck

dull tangle
#

@dire vortex have you tried using nohup? Not too familiar with detaching from parent processes but that in theory should work?

novel pulsar
dire vortex
dire vortex
wispy kestrelBOT
#

Gave +1 Rep to @novel pulsar

mortal flint
#

@magic falcon (or anyone with thoughts/comments), what's your preferred python virtual env? Seems pipenv is the way to go these days, or am I wrong?

magic falcon
#

Super easy to use, allows me to intuitively segregate my python depencies

mortal flint
#

I've read that pipenv is a bit more modern/powerful, but haven't dug into either

magic falcon
#

it very well could be

#

but venv is guaranteed to be available, because its the official python supported version

mortal flint
#

gotcha. Thanks

magic falcon
#

a lot of places where i write python, i can't get access to pip, so reducing external dependencies is a key feature for me

mortal flint
#

yeah, that's reasonable

#

in one of my current use cases, that's not an issue. In the other, it might be ๐Ÿ™‚

magic falcon
#

and i have not yet found a use-case inwhich venv is insufficient for my purposes

mortal flint
#

fair enough. Thanks for the insight ๐Ÿ™‚

#

+rep @magic falcon

wispy kestrelBOT
#

Gave +1 Rep to @magic falcon

warped axle
#

does anyone know how i can extract plaintext from .docx documents with rust?

#

i have googled for a bit and found some crates but nothing seems to points to extracting plaintext but instead extract in the form of structs and one that is the closest to what i need was writen 3 years ago which i cant seem to get working

atomic parrot
#

I don't know anything about rust, but if you run a binwalk on a .docx file and extract it you will see plenty of xml files and one of them may contain the plaintext you need, so I guess you could try to check the number of bytes and then try to start reading with that offset using rust. I hope this makes sense, but then again, no idea about rust

warped axle
#

well i tried that but couldnt seem to find the file that contained the plaintext

#

nvm i found it

#

thanks @atomic parrot

atomic parrot
#

you're welcome ;D

surreal bronze
#

@warped axle believe it's in the "document.xml" when extracted ๐Ÿ™‚

warped axle
#

i need help again i cant programmatically read the plain text from the document theres one way i've found which is on the terminal by unzipping the doc and piping it through sed with a regex patern

#

im trying to do that but with code and im strugling hard

#

pls Halp

warped axle
#

theres also the docx crate which there doesnt seem to have a read plain text function

onyx merlin
# warped axle does anyone know how i can extract plaintext from `.docx` documents with rust?
Toptal Engineering Blog

DOCX is the de facto standard for exchanging business documents, and there's no good alternative to replace it. However, DOCX is a complex format, and there are plenty of cases where someone may want to parse it manually for simpler tasks.

In this article, Toptal freelance developer Stepan Yakovenko shows us how ...

warped axle
#

hmmm will check that out thank u

lilac holly
#

what's your level of experience with programming ? Will C be your first language ?

warped axle
#

Yea i dont reccomend c being your first language

graceful needle
#

What about C++ ?

pseudo mist
warped axle
#

Bruh

#

Also youtube is a good one to start

graceful needle
#

You're bound to find some good stuff there yes. FreeCodeCamp has some good material. This is not a paid endorsement, fyi

surreal bronze
#

I recommend python for beginners, but its up to you

surreal bronze
restive fossil
#

is it possible to have multiple while true loops in a python program

onyx merlin
#

Possible? Depends how you define it
Useful? Maybe not, definitely not if they're nested

mortal flint
#

you could nest them, but that seems like really bad practice. You'd need to have some sort of break condition for both.

onyx merlin
#

At that point, while condition: is much more readable for me

graceful needle
true pumice
restive fossil
onyx merlin
#

At the same time? Then you need threads

restive fossil
#

any good articles on how to use threads

#

dont have much experience with threads

graceful needle
#

Thanks @true pumice !

wispy kestrelBOT
#

Gave +1 Rep to @true pumice

sharp coral
#

wondering what best practices are regarding the use of global variables in python, I see some people say to stay away from them but Im not sure why.

In my case I have some constants that are mostly lists, I use one function with itertools to build out these lists and use the lists elsewhere in another function, but not sure if this is the "best" way despite it just working.

URL = str(argv[1])
WORD_FILE = argv[2]
USERS = ["user1", "user2", "user3"]
WORDLIST = []
USERPASS = []

def list_builder():
    global USERPASS
    global WORDLIST
    with open(WORD_FILE, encoding="ascii", errors="ignore") as words:
        reader = words.readline()
        while reader != "":
            WORDLIST.append(reader.strip())
            reader = words.readline()
    USERPASS = list(itertools.product(USERS,WORDLIST))
true pumice
#

The formatting on mobile is horrible so I might be missing something while looking through your program.

Global variables, generally, people do avoid but you can always code in a way that you donโ€™t need any variables to be Global, such as arguments/ parameters and returning values from a function.

From looking at your program on Discordโ€™s horrible formatting, it looks like you could just initialise the two variables inside your function and return them either as a Tuple or however you want to return them, I could be mistaken although.

If it works, is efficient and the program has a good flow (easily understood), I see no problems with global variables.

While Iโ€™m no professional, I would probably avoid them if it makes the code messy or if your program is not a personal project, i.e. you are the only person using it. This is because generally you understand what the program does, whereas an outsider may not*

sharp coral
#

it looks like you could just initialise the two variables inside your function and return them either as a Tuple or however you want to return them

#

this is the right answer Im pretty sure

sharp coral
wispy kestrelBOT
#

Gave +1 Rep to @true pumice

true pumice
#

Let me know blobfingerguns

magic falcon
magic falcon
sharp coral
magic falcon
#

Jabba's recommendations aren't really python specific, it's very common to pass by reference or pass by value by reference to init variables within a scoped context.

mortal flint
magic falcon
#

Is there a python use-case where a global variable isn't tied to a namespace?

#

I can't think of one off-hand

solar hull
#

functions have their own scope as well.

lilac holly
#

this program below gives sum of consecutive no.s

M = list(range(N+1))
first_digit = M[1]
last_digit = M[-1]
sum_of_cons_no = (N/2) * (first_digit + last_digit)
print(int(sum_of_cons_no))```
is there any other way to do the same using loops?
tulip ibex
#
sum = 0
la = int(input('last number: '))
for i in range(inp,la+1):
    sum = sum+i
print(sum)```

try this it works
#

it does 1+2+3

#

oh yea thanks a lot!, i editted it in the edittor but forget it here lol

tulip ibex