Python for Cybersecurity Using Python for Cyber Offense and Defense 1st Edition Howard E. Poston instant download
Python for Cybersecurity Using Python for Cyber Offense and Defense 1st Edition Howard E. Poston instant download
https://ebookmeta.com/product/python-for-cybersecurity-using-
python-for-cyber-offense-and-defense-1st-edition-howard-e-poston/
https://ebookmeta.com/product/python-for-cybersecurity-using-
python-for-cyber-offense-and-defense-1st-edition-poston-iii/
https://ebookmeta.com/product/python-programming-for-
cybersecurity-a-comprehensive-handbook-for-beginners-1st-edition-
bytebazzar-publications/
https://ebookmeta.com/product/python-tools-for-scientists-an-
introduction-to-using-anaconda-jupyterlab-and-python-s-
scientific-libraries-1st-edition-lee-vaughan/
https://ebookmeta.com/product/dk-eyewitness-the-greek-islands-dk-
eyewitness/
The NFT Handbook How to Create Sell and Buy Non
Fungible Tokens 1st Edition Matt Fortnow
https://ebookmeta.com/product/the-nft-handbook-how-to-create-
sell-and-buy-non-fungible-tokens-1st-edition-matt-fortnow/
https://ebookmeta.com/product/you-re-so-dead-1st-edition-ash-
parsons-parsons/
https://ebookmeta.com/product/putting-psychology-in-its-place-
critical-historical-perspectives-4th-edition-graham-richards-2/
https://ebookmeta.com/product/hr-here-and-now-the-making-of-the-
quintessential-people-champion-1st-edition-ganesh-chella/
https://ebookmeta.com/product/callum-s-hope-a-curvy-girl-holiday-
romance-silver-spoon-falls-1st-edition-nichole-rose/
Special Issue Law and the Imagining of Difference 1st
Edition Austin Sarat
https://ebookmeta.com/product/special-issue-law-and-the-
imagining-of-difference-1st-edition-austin-sarat/
Python® for Cybersecurity
Using Python for Cyber Offense
and Defense
978-1-119-85064-9
978-1-119-85070-0 (ebk.)
978-1-119-85065-6 (ebk.)
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for
permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ
07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permission.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought. Nei-
ther the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website
is referred to in this work as a citation and/or a potential source of further information does not mean that the author
or the publisher endorses the information the organization or Website may provide or recommendations it may make.
Further, readers should be aware the Internet Websites listed in this work may have changed or disappeared between
when this work was written and when it is read.
For general information on our other products and services or for technical support, please contact our Customer Care
Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available
in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.
Trademarks: WILEY and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or
its affiliates, in the United States and other countries, and may not be used without written permission. Python is a
registered trademark of Python Software Foundation. All other trademarks are the property of their respective owners.
John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
Howard E. Poston III is a freelance consultant and content creator with a focus
on blockchain and cybersecurity. He has developed and taught more than a
dozen courses exploring and explaining various aspects of cybersecurity and
has written hundreds of articles on the subject on different outlets. Howard
Poston is also the author of several academic articles on security topics, and has
spoken on blockchain and cybersecurity at international security conferences.
Acknowledgments
Thanks to my technical editor, Ben Heruska, and the amazing team at Wiley
without whom this book would not have been possible.
iv
About the Technical Editor
v
Contents at a Glance
Introductionxvii
Chapter 1 Fulfilling Pre-ATT&CK Objectives 1
Chapter 2 Gaining Initial Access 19
Chapter 3 Achieving Code Execution 39
Chapter 4 Maintaining Persistence 55
Chapter 5 Performing Privilege Escalation 77
Chapter 6 Evading Defenses 89
Chapter 7 Accessing Credentials 105
Chapter 8 Performing Discovery 125
Chapter 9 Moving Laterally 141
Chapter 10 Collecting Intelligence 157
Chapter 11 Implementing Command and Control 169
Chapter 12 Exfiltrating Data 183
Chapter 13 Achieving Impact 199
Index213
vii
Contents
Introductionxvii
Chapter 1 Fulfilling Pre-ATT&CK Objectives 1
Active Scanning 2
Scanning Networks with scapy 2
Implementing a SYN Scan in scapy 4
Performing a DNS Scan in scapy 5
Running the Code 5
Network Scanning for Defenders 6
Monitoring Traffic with scapy 7
Building Deceptive Responses 8
Running the Code 9
Search Open Technical Databases 9
Offensive DNS Exploration 10
Searching DNS Records 11
Performing a DNS Lookup 12
Reverse DNS Lookup 12
Running the Code 13
DNS Exploration for Defenders 13
Handling DNS Requests 15
Building a DNS Response 15
Running the Code 16
Summary17
Suggested Exercises 17
Chapter 2 Gaining Initial Access 19
Valid Accounts 20
Discovering Default Accounts 20
Accessing a List of Default Credentials 21
Starting SSH Connections in Python 22
ix
x Contents
HADEE
RESTORATION
“Well, it isn’t as bad as it might be,” said Dr. Morse after he had
examined Hadee. “Of course it would have been better to have had
the bone set sooner, but there’s no great harm done. But I must get
her to some other place than this to work over her. I haven’t room
here.”
“Take her to our camp,” proposed Natalie.
“No, she wouldn’t ride well in a boat. I’ll just send Old Hanson
back for a farm wagon, and have him put a mattress in it. She can
ride on that as well as in an ambulance. I guess the Richardson’s will
take her in. They have plenty of room. I was just there on a call
when Hanson found me. Mr. Richardson has a little bilious attack.
This girl will be very comfortable there. His wife is a fine cook, and
they have hired help.”
Dr. Morse explained to Old Hanson what was wanted, and the
hermit started off after the wagon. Hadee was gotten downstairs,
and made as comfortable as possible.
The Camp Fire Girls were anxious to hear her story but Dr. Morse
would not let her talk.
“It will do later,” he said. “She has a slight fever, and I don’t want
any more inflammation in that leg than I can help.”
There was the sound of wheels down the road. A farm wagon
hove in sight, Old Hanson sitting on the seat beside the driver.
As Hadee was carried out the old hermit, who had been hovering
about caught a glimpse of her face. He started, took a few steps
forward, clutched at his heart and cried:
“Girl—girl! Who was your mother?”
“Hush! We mustn’t have any excitement,” warned the doctor,
thinking the old man’s mind, never considered strong, was leading
him astray.
“Her mother! Her mother!” cried Hanson. “I can see her mother’s
face! She is my daughter’s child—I know it. She has been restored to
me! Oh, child, where is your mother?”
“Now—now!” protested Dr. Morse. “You can’t——”
But Hanson had pushed his way forward, and was now beside the
wagon, in which Hadee lay on the mattress. There was a flush on
her pale face.
“What does he mean?” she asked slowly.
“I don’t know,” answered Dr. Morse testily.
“I’ll explain!” said Hanson eagerly. “I’m not crazy—let me talk.
Everybody doesn’t know my story—some around here do—you do,
Dr. Morse. I tell you that girl is my daughter’s child. Tell me,” he
appealed to Hadee, “do you know who your mother and father
were?”
“They are both dead,” she said softly, “but I have been told that
my mother was not a Gypsy.”
“Of course she was not!” cried Hanson. “She was my daughter,
and she ran away and married a Gypsy—a handsome chap he was,
too. It broke my heart—it made me lose all hope in life. But now my
granddaughter is restored to me. And so you were the ghost of the
mill?”
“I hid there after I ran away,” said Hadee. “I wouldn’t do as they
wanted me to——”
“You had better not talk, dear,” said Mrs. Bonnell gently placing
her hand on the girl’s hot forehead.
“Oh, well, maybe she’ll feel better to have it over with,” said Dr.
Morse resignedly. “Are you sure about this, Hanson?”
“Positive. She is the image of my lost daughter. She must have a
birth-mark on her neck—all the Rossmore’s had it.”
“There is a mark there,” said Natalie. “I saw it.”
“And are you really my grandfather?” murmured Hadee.
“I sure am, girl.”
“Then I’m not a Gypsy.”
“Only half; and you won’t be that much any more. You’re coming
to live with me. I’ve got a little money put away, and we’ll live for
each other now. I couldn’t keep my daughter—maybe I was too
harsh with her—but I won’t be with you, Hadee,” and he gazed
lovingly at her.
“Now, this will just have to stop!” declared Dr. Morse firmly. “I
insist on the patient being kept quiet. She may be your daughter’s
child, Hanson, but if you want to keep her with you don’t set her
into more of a fever than she has already. Drive on, Pete. I’ll follow
in my carriage. See you later,” he called to the Camp Fire Girls and
their boy friends.
“Well, what do you know about this?” gasped Jack, as the carriage
of the doctor and the other wagon disappeared down the road. “You
girls have certainly beaten us all to pieces! You discover the ghost,
get back the diamond ring and restore a long-lost child to her
grandfather. Wow!”
“Tell us all about it,” demanded Blake.
“We can’t until we hear Hadee’s story,” said Natalie.
And they heard that the next day. The broken leg had been set,
and put in a plaster cast. Then, with the permission of Dr. Morse,
Hadee, sitting up in bed in the Richardson home, told her story.
She had been with the Gypsy band all her life, traveling about the
country. When she became old enough her mother had told her
something of the tragedy of her own story. Hanson Rossmore’s
daughter had met a handsome Gypsy lad, and fallen in love with
him. Her father opposed her, but she ran away and was legally
married to him. Then, feeling unable to return to her father, the girl
took up a life with the nomads. Hadee was the only child, and when
her parents died she remained with the tribe. She became one of
the best fortune tellers.
It was Hadee who called at the Anderson home that night the ring
disappeared.
“But I did not take it,” she said. “It fell down from the table into
the folds of my sash. I discovered it when I got back to camp, but
Neezar, who calls herself our queen, would not let me take it back.
Then the camp was quickly moved away, and I did not have a
chance to return—the diamond.
“I kept it with me, however, refusing to give it up, though they
tried to make me. Life was very hard. Then came the taking of the
farmer’s wife’s pocket-book. I did not do that, it was another of our
band who used my name. When I heard of the trouble I tried to run
away, but they watched me too close.
“Finally I got the chance, and, I came to this old mill. I stayed
here nights and went out by day, as I could, to get food. I guess I
took something from my grandfather here, and from your camp,”
she said, with a shy smile at the boys. “I needed things. There was a
handkerchief——”
“Mine—but you may keep it,” said Blake.
“And the canoe,” went on Hadee. “The boat I came in drifted
away.”
“Jove! It’s good to get that canoe back,” said Jack.
“It’s hidden back of the mill,” went on the Gypsy girl. “I have
stayed here ever since.”
“And was it your face I saw at the window?” asked Natalie.
“Yes,” assented Hadee. “I was afraid you would come and find me
that time. Then I found the secret room, and stayed there. I stole
softly down in the night when the boys were here, and took some of
their things when they were asleep,” she said shyly. “I needed
them.”
“Oh, we were easy marks,” admitted Phil with a laugh.
“I needed the knife and matches,” the Gypsy girl went on, “but I’ll
give them back. The food I ate.”
“You’re welcome to it,” said Blake kindly.
“I also took a few things from your camp,” she said to the girls.
“The olives and sardines?” asked Marie.
Hadee nodded.
“I was sorry when—when my grandfather moved out. I didn’t
know he was any relative,” she resumed. “I didn’t mean to scare
him, but I suppose I did. I cried because I was lonesome and
afraid.”
“That’s all right!” exclaimed Hanson Rossmore. “As long as I’ve got
some kin now, I don’t mind. I’m going to sell the old mill—I’ve got
an offer for the property, and we’ll live together where nothing will
remind us of it—Ethel Rose.”
“Ethel!” exclaimed Natalie. They could all see how much Natalie
resembled the Gypsy girl.
“Yes, I’m going to call her that,” said the old man. “I don’t want
any more Gypsy names.”
“Well, I guess that explains everything,” said Jack. “So there was
no ghost after all.”
“No. And Natalie proved it!” declared Marie. “Oh, you dear girl!”
and she put her arms around her chum.
“Let’s get back to camp and have a celebration,” proposed Jack.
“We’ll have enough to talk about for a month.”
Hadee, or Ethel Rose Rossmore, to give her the name she was
thenceforth to bear, rapidly recovered from her accident, and she
and her grandfather made arrangements to board in the village until
he could dispose of his property. The Gypsy camp was broken up, its
members going whither no one knew. There were many complaints
about them for small thefts, and arrests had been planned but too
late.
After all the excitement quiet days followed. There were Council
meetings and camp-fires, walks in the woods and cruises on the
lake, when many songs were sung. Cora, Gertrude, Edna, Sadie and
Margaret also paid a visit to the woods.
Mabel telegraphed the good news of the finding of the diamond
ring to her mother, and the boys found their missing canoe and
lantern where the Gypsy girl had left them.
“And so the mystery of the old mill is settled,” remarked Blake, as
he and Natalie walked along the lake shore one day.
“Yes. It was like most ghosts—easily accounted for when you go
at it right.”
“But if it hadn’t been for you it might never have been solved.”
“Oh, some one would have found poor little Hadee if I hadn’t.”
“Will you come over to the Point and dance to-night?” asked
Blake, after a pause.
“Yes, if the others go. We won’t have many more chances. We are
going to break camp next week.”
“So are we. Hasn’t it been a glorious summer?”
“Indeed, yes. All the girls are delighted with the Camp Fire idea.
They are talking now of a winter in the woods.”
“Why not?” asked Blake. “A log cabin is the best place ever, in the
snow.”
“Perhaps we may,” assented Natalie, and as she and Blake strolled
on through the spicy woods, some one called:
“Wo-he-lo! Dogwood camp! Natalie!”
“They want me to come back,” said Natalie, softly.
“Don’t go yet,” begged Blake, and Natalie stayed.
THE END.
The next volume of this series will be entitled: “Camp Fire Girls on
The Ice; Or, the Mystery of a Winter Cabin.”
Boy Inventors’ Series
The author knows these subjects from a practical standpoint. Each
book is printed from new plates on a good quality of paper and
bound in cloth. Each book wrapped in a jacket printed in colors.
Price 60c each
1 Boy Inventors’ Wireless Triumph
2 Boy Inventors and the Vanishing Gun
3 Boy Inventors’ Diving Torpedo Set
4 Boy Inventors’ Flying Ship
5 Boy Inventors’ Electric Ship
6 Boy Inventors’ Radio Telephone
2
Woodcraft; or, How a Patrol Leader Made Good
3
Pathfinder; or, the Missing Tenderfoot
4
Great Hike; or, The Pride of Khaki Troop
5
Endurance Test; or, How Clear Grit Won the Day
6
Under Canvas; or, the Search for the Carteret Ghost
7
Storm-bound; or, a Vacation among the Snow Drifts
8
Afloat; or, Adventures on Watery Trails
9
Tenderfoot Squad; or, Camping at Raccoon Bluff
10
Boy Scouts in an Airship
11
Boy Scout Electricians; or, the Hidden Dynamo
12
Boy Scouts on Open Plains
For Sale by all Book-sellers, or sent postpaid on receipt of 40 cents
M · A · DONOHUE · & · COMPANY
711 · SOUTH · DEARBORN · STREET · · CHICAGO
*** END OF THE PROJECT GUTENBERG EBOOK THE CAMP FIRE
GIRLS; OR, THE SECRET OF AN OLD MILL ***
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty