Skip to content

Commit

Permalink
hstrip extended by the "hexdump" arg, which allow to transfer series …
Browse files Browse the repository at this point in the history
…of char to clean (clipboard not used)
  • Loading branch information
NexSabre committed May 4, 2021
1 parent 7ab534a commit 10df57b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.10.1
* hstrip extended by the "hexdump" arg, which allow to transfer series of char to clean (clipboard not used)

v0.10
* Add support for the hstrip

Expand Down
14 changes: 12 additions & 2 deletions scapy_helper/utils/hstrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@
"""


def hstrip(raw=True):
striped_value = [x.split() for x in pyperclip.paste().split("\n") if x.strip() != ""]
def hstrip(raw=True, hexdump=None):
"""
Clean a Scapies hexdump into more friendly "oneliner"
:param raw: If False, return oneliner
:param hexdump: String: If you want to manually transfer series of chars
:return: String
"""
if not hexdump:
striped_value = [x.split() for x in pyperclip.paste().split("\n") if x.strip() != ""]
else:
striped_value = [x.split() for x in hexdump.split("\n") if x.strip() != ""]

if getenv("SH_DEBUG", False):
striped_value = [x.split() for x in HEXDUMP_VALUE.split("\n") if x.strip() != ""]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
long_description_content_type="text/markdown",
author="Nex Sabre",
author_email="[email protected]",
version="0.10.0",
version="0.10.1",
url="https://github.com/NexSabre/scapy_helper",
packages=find_packages(),
classifiers=[
Expand Down
7 changes: 6 additions & 1 deletion test/utils/test_hstrip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import unittest
from unittest import TestCase

from pyperclip import PyperclipException
Expand Down Expand Up @@ -30,3 +29,9 @@ def test_hstrip(self):
hstrip(raw=False),
HSTRIP_RESULT
)

def test_hstrip_from_hexdump(self):
self.assertEqual(
hstrip(raw=False, hexdump=HEXDUMP_VALUE),
HSTRIP_RESULT
)

0 comments on commit 10df57b

Please sign in to comment.