Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:43:22+00:00 2026-06-07T14:43:22+00:00

I am attempting to call two_byte_proc(payload,offset) from within process() but it does not write

  • 0

I am attempting to call two_byte_proc(payload,offset) from within process() but it does not write to the output file out_buf. The output from offset or payload may contain None so those iterations should be skipped and restart the process function with the next packet.

def process():
    pkts = sniff(offline="infile.pcap",filter="tcp")
    out_buf = open("outfile.bin","wb")

    for pkt in pkts:
        offset = hexdump(str(pkt.payload)[:2])
        payload = hexdump(pkt.payload)

        if offset or payload is None:
            pass
        else:
            out_buf.write(two_byte_proc(payload,offset))

process()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:43:24+00:00Added an answer on June 7, 2026 at 2:43 pm

    The expression offset or payload is None is always True; perhaps you meant:

    if offset is None or payload is None:
    

    instead.

    Since you ‘pass’ if that expression is True, you may as well reverse it:

    if offset is not None and payload is not None:
        out_buf.write(two_byte_proc(payload, offset))
    

    I suspect that offset and payload are either strings with length > 0 or None, in which case that can be further simplified to:

    if offset and payload:
        out_buf.write(two_byte_proc(payload, offset))
    

    Last but not least, you need to make sure that two_byte_proc (or four_byte_proc after your edit) actually returns something to write to out_buf. If all it returns is an empty string, for example, you won’t see any results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to call the Apache Commons StringUtils.join() method from within a Groovy
Morning Everyone, I've been attempting to write an application that does some GETs from
I am attempting to call a function but the error I am getting is
I'm attempting to build a method call from strings that have been passed into
I'm attempting to execute a .NET (3.5) command line program from within a VBScript
I'm attempting to use AJAX to call make a SOAP call (not cross-site, so
I'm attempting to write a function that recursively computes the resulting fibonacci number from
I am attempting to write a readonly file to my SD card. I need
I'm attempting to call a function in the ROOT plotting package that accepts three
I'm attempting to call a stored proc on my local SQL Server (2008 R2)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.