exploit development – how to overflow fgets asm x86 32 bits. i want to give a input from a file such that i overwrite the local variable

; Fill buffer with data from standard input.
; Buffer is stored on the stack.
;

extern printf
extern puts
extern strlen
extern gets
extern fgets
extern stdin

section .data
    read_message: db "insert buffer string: ", 0
    buffer_intro_message: db "buffer is:", 0
    byte_format: db " %02X(%c)", 0
    null_string: db 0
    var_message_and_format: db "var is 0x%08X", 13, 10, 0

section .text

global main

main:
    push ebp
    mov ebp, esp

    ; Make room for local variable (32 bit, 4 bytes).
    ; Variable address is at ebp-4.
    sub esp, 4

    ; Make room for buffer (64 bytes).
    ; Buffer address is at ebp-68.
    sub esp, 64

    ; Initialize local variable.
    mov dword (ebp-4), 0xCAFEBABE

    ; Read buffer from standard input.
    push read_message
    call printf
    add esp, 4

    lea ebx, (ebp-76)
    push dword (stdin)
    push 64
    push ebx
    call fgets
    add esp, 12


    ; Push string length on the stack.
    ; String length is stored at ebp-72.
    push ebx
    call strlen
    add esp, 4
    push eax

    ; Print data in buffer.
    push buffer_intro_message
    call printf
    add esp, 4

    xor ecx, ecx
print_byte:
    xor eax, eax
    lea ebx, (ebp-76)
    mov al, byte(ebx+ecx)
    push ecx    ; save ecx

    ; Print current byte.
    push eax
    push eax
    push byte_format
    call printf
    add esp, 12

    pop ecx ; restore ecx
    inc ecx
    cmp ecx, (ebp-76)
    jl print_byte

    push null_string
    call puts
    add esp, 4

    ; Print local variable.
    mov eax, (ebp-4)
    push eax
    push var_message_and_format
    call printf
    add esp, 8

    leave
    ret

javascript – How to set an an active class to a variable – React

My first question on S.O. let’s see how it goes.

I’m trying to set the “active class” to a variable in my Home.js, and pass down the value, as a prop to my <Buddy /> component. Once there I will set that to an integer to decide what slide my text carousel goes to. I’ll figure out that part (but if you know, spare me the time).

I’m using an npm package react-scroll to scroll to that component once clicked. Then the component is set to “active”. I will drop some code.

  1. Nav bar section in the Home.js component..
return (
<div className="navBar">

   <div className="navItem">
        <Link
           activeClass='active'
           to="home"
           spy={true}
           smooth={true}
           offset={0}
           className='nav-Link'>
            <h2>Home</h2>
        </Link>
    </div>
       
    <div className="navItem">
       <Link
           activeClass='active'
           to="projects"
           spy={true}
           smooth={true}
           offset={0}
           className='nav-Link'>
               Projects
        </Link>
     </div>
       
     <div className="navItem">
       <Link
           activeClass='active'
           to="mission"
           spy={true}
           smooth={true}
           offset={0}
           className='nav-Link'>
               Mission
        </Link>
      </div>
       
     <div className="navItem">
       <Link
           activeClass='active'
           to="about"
           spy={true}
           smooth={true}
           offset={0}
           className='nav-Link'>
               About
        </Link>
     </div>
       
     <div className="navBar">
       <Link
           activeClass='active'
           to="contact"
           spy={true}
           smooth={true}
           offset={0}
           className='nav-Link'>
               Contact
        </Link>
     </div>

</div>
  1. My component sitting right beneath.
<Buddy />
  1. Each component on my SPA/Portfolio has an id that the on my nav bar looks to go to.
//Projects.js

const Projects = () => {
    return (
        <div className="projectsComponent" id="projects">
            
        </div>
    )
}

So when it scrolls to the component, it sets that div? or component? to active.

// back in Home.js

<div className="navItem">
        <Link
            activeClass='active' <-----------
            to="projects"
            spy={true}
            smooth={true}
            offset={0}
            className='nav-Link'>
                Projects
            </Link>
        </div>

I just want to set whatever I need to, into a variable in Home.js to pass down as a prop to <Buddy />. Thanks, guys! Remember it’s my first question ever! Be nice!

** If you have a better idea, like when the scroll reaches that component, set the index of my carousel to 1,2,3.. let me know too. Thanks

*** I will also include my <SpeechCarousel /> component here. It lives in my <Buddy /> component and ill pass another prop to it. Thanks again.

import React, {useState} from 'react'
import Carousel from 'react-bootstrap/Carousel'
import "../styles/css/Buddy.css"

const SpeechCarousel = () => {
    const (index, setIndex) = useState(0);
  
    const handleSelect = (selectedIndex, e) => {
      setIndex(selectedIndex);
    };

    return (
        <div id="carousel2">
      <Carousel activeIndex={index} onSelect={handleSelect} interval={null}>
        
        <Carousel.Item className="car2item">
          <p>TEXT</p>
        </Carousel.Item>

        <Carousel.Item className="car2item">
        <p>TEXT</p>
        </Carousel.Item>

        <Carousel.Item className="car2item">
        <p>TEXT</p>
        </Carousel.Item>

        <Carousel.Item className="car2item">
        <p>TEXT</p>
        </Carousel.Item>

        <Carousel.Item className="car2item">
        <p>TEXT</p>
        </Carousel.Item>

     </Carousel>

      </div>
    )
}
export default SpeechCarousel;

How to assign an image to a variable so that it can be changed in one place and displayed on many pages. – HTML & CSS

I have an HTML & CSS website with many pages and the same photo displayed on top. I would like to find a way to change the photo & its width & height in one place and have it display on those multiple pages without changing each page individually, which is what I am doing now but there are now just too many pages. I am not sure how to do this in either html, ccs or maybe even javascript. 1972.naures.com is the website if this helps. I tried to google the answer but I think I don’t quite know enough about these languages to know if I even found the answer. – Thanks for any help you can give.

How to transfer number in a string to multiple variable in PEP/8 assembly

Basically, I have a string that look like this

"K 123 84 657 483 156 1584"

How do I go about storing those 6 numbers in 6 different variable in PEP/8?

thanks for the help!

Parsing a fixed-size message using variable length array in C

My C program has to parse a fixed-length message like this:

uint8_t message(8) = {80, 75, 73, 71, 1, 1, 1, 1};

another message could be:

uint8_t message(8) = {80, 75, 73, 71, 41, 42, 1, 1};

The message contains an ASCII string and 1 shows the end of string. So the actual length of the first message is 4 and the second message is 6.

I use this method to extract the message:

1. Counting the message length
2. Initializing a variable length array with this value.
3. Using memcpy to copy the bytes.

Code Snippet

In the library file:

Counting the length:

...
#define LENGTH 100
// Global variables in library
uint8_t message(LENGTH);
uint8_t parsed_message(LENGTH);
uint8_t len = 0;
...

for (int i = 0; i < LENGTH; i++)
    {
        if (message(i) != 1)
        {
            parsed_message(i) = message(i);
            len++;
        }
        else
        {
            parsed_message(i) = '';
            len++;
            break;
        }

    }

Getter functions:

void get_address(char * addr, int size)
{
    memcpy(addr, message, size);
}


uint8_t get_size(void)
{
    return len;
}

In the main function:

char addr(get_size());
get_address(addr, get_size());
printf("==== %s ==== ADDRESSn", addr);

(I ommitted size and null checks in snippets)

I use GCC compiler and C99 standard in ARM-Based 32-bit micro-controller.

My question is that is this method safe? Or I should use another approach.

Line chart – do you add a legend to one variable data visualisation?

Stack Exchange Network


Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

passing variable values to procedure in postgresql via psql

basically I have written a code to pass variable values via psql to my procedure is it supported?
and if supported any pointers to get it done : my code looks like below :

do $$
<<main_block>>
declare
err_msg text;
BEGIN
insert into mig.qb_items (qb_id , sync_token , qb_updated_at , qb_created_at , qb_expired_at , name , sku , description , active , qb_parent_id , taxable , unit_price , transaction_type , category_type , qb_income_account_id , qb_expense_account_id , purchase_description , tax_included , purchase_cost , qb_asset_account_id , track_quantity , inventory_start_date , quantity_on_hand , qb_sales_tax_id , qb_tax_code_id , abatement_rate , reverse_charge_rate , service_type , level, created_at , updated_at , expired_at , ancestor_id , signature , financial_signature , qb_object , print_grouped_items, company_id )
select qb_id , sync_token , qb_updated_at , qb_created_at , qb_expired_at , name , sku , description , active , qb_parent_id , taxable , unit_price , transaction_type , category_type , qb_income_account_id , qb_expense_account_id , purchase_description , tax_included , purchase_cost , qb_asset_account_id , track_quantity , inventory_start_date , quantity_on_hand , qb_sales_tax_id , qb_tax_code_id , abatement_rate , reverse_charge_rate , service_type , level , created_at , updated_at , expired_at , ancestor_id , signature , financial_signature , qb_object , print_grouped_items, :tenant_id as company_id from :schema.qb_items;
update mig.migration_status set status=’COMPLETED’ WHERE schema=:tenant and table_name=’qb_items’;
EXCEPTION WHEN others THEN
GET STACKED DIAGNOSTICS err_msg = MESSAGE_TEXT;
update mig.migration_status set status=’FAILED’ WHERE schema=:tenant and table_name=’qb_items’;
raise notice ‘EXCEPTION %’, err_msg;
END main_block;
$$;

bt i am getting error as below :

psql:/home/ec2-user/scripts/qb_items.sql:14: ERROR: syntax error at or near “:”
LINE 7: …cial_signature , qb_object , print_grouped_items, :tenant_id…

How to check a variable? !/bin/sh shell script

Im really noob in scripting. Im trying to improve.
I want to check if a variable has only alphabetical and numeric characters:

str="3dr>f43fe*" –> Not good
str2="RFEfew3" –> Good

How should I do it?

evaluation – How to inline a variable in function definition

I need to compile a function g that calls an external function f. f and g are defined as such:

r = {0,0,1};
f = # - r &;
g = Compile[{{a, _Real}}, f[a], CompilationOptions -> {"InlineExternalDefinitions" -> True}]

But this way r will be held, and g will assume it to be a real number instead of a vector, throwing type error when trying to find a - r. How can I inline r such that f = # - {0,0,1}&? Evaluate doesn’t work because the result will be f = {#, #, #-1}&.

unity – Iterate over a loop to calculate a sum, or update a sum variable as items are added and deleted from a list?

I thought I ran into this concept at one point but can’t figure out how to find an answer for it.

Is it better to iterate over a list of ints to calculate a running sum each frame, or is it better to create a variable to hold the sum and to increase or decrease it as numbers are added to the list?

The only downside I see for keeping a sum variable around is that you have to make sure you really update it correctly in all niche cases that might appear. Or ensure that items are removed from the list correctly, say, on death.