PowerShell Security - Friedrich Weinmann - PSConfEU 2022
الملخص
TLDRIn this presentation, Fred from Microsoft discusses the relevance of PowerShell in maintaining a secure Windows environment while addressing concerns related to its potential misuse by attackers. He emphasizes that PowerShell, often perceived as a security risk, is actually vital for automation and administrative tasks. Fred provides strategies for organizations to manage and secure PowerShell use, including leveraging logging, execution policies, Constrained Language Mode, and application whitelisting. He outlines common misconceptions about PowerShell's security features and provides insight into best practices for integrating it safely into corporate environments.
الوجبات الجاهزة
- 🔑 PowerShell is a powerful tool for automation and security.
- 🚫 Disabling PowerShell can lead to unsupported environments.
- ✅ Application whitelisting is essential for security.
- 🧐 Execution policies do not guarantee security.
- 🔍 Use logging to track and monitor PowerShell usage.
- 🔒 Constrained Language Mode limits script capabilities.
- 🛡️ Regularly update PowerShell to enhance security.
- ⚙️ Ensuring only trusted code runs is critical for protection.
- 📈 Security best practices must evolve with emerging threats.
- 🤝 Engage admins in secure coding practices for better compliance.
الجدول الزمني
- 00:00:00 - 00:05:00
The speaker, Fred, introduces himself as a custom engineer at Microsoft. He discusses the significance of PowerShell in his work and the common misconceptions about its security risks due to malware, especially among higher management who feel compelled to disable it rather than utilize its capabilities.
- 00:05:00 - 00:10:00
Fred emphasizes that despite the concerns surrounding PowerShell, it is actually one of the most secure languages available for automation. He uses a metaphor comparing cybersecurity to a castle, explaining that simply disabling PowerShell is akin to a false sense of security.
- 00:10:00 - 00:15:00
He points out that the idea of disabling PowerShell might seem appealing but is ultimately ineffective against real threats, as attackers have a variety of languages and methods at their disposal. He argues that understanding PowerShell and monitoring its use can provide greater security benefits.
- 00:15:00 - 00:20:00
To combat requests for disabling PowerShell, Fred highlights the importance of understanding its integration within the Windows ecosystem and that the entire system relies on it being enabled for proper function, which emphasizes the risk of disabling it.
- 00:20:00 - 00:25:00
Fred debunks the myth that execution policies in PowerShell serve as a security measure, clarifying that execution policies do not genuinely prevent malicious scripts from running. He discusses the importance of having the latest PowerShell versions to ensure security features are up to date.
- 00:25:00 - 00:30:00
He discusses the need for application whitelisting and controlling executed PowerShell versions to prevent potential exploits. He underlines the monitoring requirement, suggesting that version 2 of PowerShell should be uninstalled, but also points out the limitations in simply removing older versions from machines.
- 00:30:00 - 00:35:00
The talk highlights various security measures such as code signing, auditing remoting connections, and how to manage external code. Fred stresses that administrative processes should be rigid to maintain organizational security without posing significant operational disruptions.
- 00:35:00 - 00:40:00
Fred covers logging in PowerShell, distinguishing between its different methods and focusing on script block logging as the most effective method to understand what is being executed. He expresses the importance of continuous monitoring and an understanding of usage patterns for security events.
- 00:40:00 - 00:48:49
Finally, Fred wraps up with a reminder that proper implementation of these security practices requires an understanding of the technical landscape and process management within organizations. He encourages adopting source control practices and proper code approval workflows to bolster security.
الخريطة الذهنية
فيديو أسئلة وأجوبة
Why should we not disable PowerShell?
Disabling PowerShell removes a crucial automation tool for security and administration tasks, potentially leading to unsupported environments and operational issues.
What are the main risks associated with using PowerShell?
Risks include exploitation by attackers if proper security measures are not implemented, such as logging, monitoring, and application whitelisting.
How can we secure PowerShell usage?
You can secure PowerShell by enforcing application whitelisting, using Constrained Language Mode, and implementing robust logging practices.
What is the significance of execution policies in PowerShell?
Execution policies are not security features but serve as a way to prevent unintentional script execution. They can be circumvented easily.
How does application whitelisting help?
Application whitelisting ensures that only approved and trusted scripts or executables can run, reducing the risk of unauthorized executions.
What is Constrained Language Mode?
Constrained Language Mode limits the functionalities available to PowerShell scripts that are not trusted, significantly reducing the capabilities of potential attackers.
How can older PowerShell versions affect security?
Older PowerShell versions may lack security enhancements and features, making systems vulnerable. Regular updates are necessary to maintain security.
What logging features are recommended for PowerShell?
Script block logging and module logging are recommended as they provide detailed records of what is executed, aiding in monitoring and incident response.
How can we manage PowerShell updates?
PowerShell can be updated through Windows Management Framework updates or package managers in a corporate environment.
What should be done about unauthorized code execution?
Implement and enforce application whitelisting to ensure only authorized code can run while monitoring for any unauthorized attempts.
عرض المزيد من ملخصات الفيديو
- 00:00:02[Music]
- 00:00:16thank you for joining us today again and
- 00:00:18i very much appreciate all of your
- 00:00:20energy to get up at 9 00 am sit here
- 00:00:23after what happened last night
- 00:00:26if i'm slightly wobbling around i might
- 00:00:30still have some left over alcohol in the
- 00:00:32blood but a little bit of fortification
- 00:00:34won't hurt today
- 00:00:36um yeah
- 00:00:38i'm fred
- 00:00:41i'm a custom engineer working for
- 00:00:43microsoft um of the customer engineering
- 00:00:45gig ads
- 00:00:46you're officially assigned to some field
- 00:00:48for example i'm infrastructure and
- 00:00:50security
- 00:00:51which is kind of nice but inside in
- 00:00:53reality we get
- 00:00:54fairly liberal about what engagements we
- 00:00:57pick what topics we cover and to
- 00:00:59everybody's surprise in the room no
- 00:01:00doubt i pick powershell
- 00:01:02lots of it every day
- 00:01:04which is fun
- 00:01:06and
- 00:01:09this one thing when somebody in the
- 00:01:11world files a ticket with microsoft if
- 00:01:13the first line support can't handle it
- 00:01:15that gets escalated internally into the
- 00:01:17proper directions
- 00:01:19so that somebody
- 00:01:21marzinio might be able to help with that
- 00:01:24and as it happens about once or twice
- 00:01:27per month the following request ends up
- 00:01:30on my table
- 00:01:36now where does this request comes from
- 00:01:38come from it's a
- 00:01:41born of ignorance of people literally
- 00:01:44being helpless not knowing what to do
- 00:01:46they read in the newspapers that there's
- 00:01:48a malware there's bad actors using
- 00:01:51powershell to hack your environment it's
- 00:01:53a danger it's a risk
- 00:01:55so they want to turn it off
- 00:01:58this especially comes admittedly from
- 00:02:00this from the sea levels and they read
- 00:02:02some tech paper because the cio kind of
- 00:02:04wants to double in its old field i mean
- 00:02:06we all know cio
- 00:02:08classic acronym for carrier is over
- 00:02:11it's it's a kind of bad fate that
- 00:02:13happens to a technician that gets
- 00:02:14promoted a few levels more than he would
- 00:02:16really be comfortable with so whenever
- 00:02:18you can make the time you try to read up
- 00:02:20to stay with your with the reality of
- 00:02:22your team but given the how busy your
- 00:02:25life is at that level the chances are
- 00:02:27you're not going to be able to do that
- 00:02:29in full depth so that's where we get
- 00:02:31this kind of request from
- 00:02:34and yeah we have to deal with that
- 00:02:37so what can we tell them
- 00:02:40the first thing i really try to tell
- 00:02:42them you know what
- 00:02:43it might attackers might be using it but
- 00:02:45actually
- 00:02:46it's your best chance
- 00:02:48it is
- 00:02:49hands down the most secured language
- 00:02:53that we have and at least from coming
- 00:02:55from microsoft running on windows
- 00:02:57and
- 00:02:58you're not going to get a better thing
- 00:03:00to automate your environment
- 00:03:02and sometimes this table alone already
- 00:03:04wins the deal
- 00:03:06which i totally did not steal from the
- 00:03:07homes
- 00:03:10that said
- 00:03:12often enough they still say hey i still
- 00:03:14want to disable it
- 00:03:17which uh yeah leaves us at the next
- 00:03:19discussion point
- 00:03:21when i try to secure an environment i
- 00:03:24like to liken it to a castle or to my
- 00:03:26home
- 00:03:27and the attackers are the burglars
- 00:03:30so when i try to shut down powershell
- 00:03:33what protection level actually would
- 00:03:34that get me
- 00:03:36you see that's down there
- 00:03:39that's the protection level as we all
- 00:03:40know all know burglars come at night
- 00:03:43they go over your lawn not just not the
- 00:03:46road that might be booby trapped
- 00:03:48they might not see the stone they might
- 00:03:49stumble over it and break a leg and you
- 00:03:51might be secure from that
- 00:03:54that's about the protective level you
- 00:03:55get from disabling powershell because
- 00:03:58you just have to kind of look at the
- 00:04:00dark net and what offerings there you
- 00:04:01can get attack packages fairly cheaply
- 00:04:04and quite a few of them say okay i'm
- 00:04:06supporting 10 different attack languages
- 00:04:08and if one of them is locked down okay
- 00:04:10just take the other
- 00:04:12and given all of these nice security
- 00:04:15features especially in the logging my
- 00:04:17opinion is in my statement officially
- 00:04:18here
- 00:04:19you should back on your knees you'll be
- 00:04:22grateful to all the attackers that are
- 00:04:24attacking you with powershell
- 00:04:26that's it's kind of like you know it's
- 00:04:28uh like putin would be uh phoning in
- 00:04:31uh zelensky and say hey tomorrow i'm
- 00:04:34gonna attack there
- 00:04:35okay or today but this is my war plan
- 00:04:37because they will be
- 00:04:39signaling everything they're doing you
- 00:04:40just
- 00:04:41need to grab the data
- 00:04:44so
- 00:04:44we're at the level of placing a stone so
- 00:04:46that's the security game it's better
- 00:04:48than not having a stone it definitely
- 00:04:49worked out for my aunt aren't that that
- 00:04:51actual comparison comes from she
- 00:04:53literally did have a burglar stumble
- 00:04:55over stone
- 00:04:57so
- 00:04:57yeah but i don't think you want to rely
- 00:04:59on being my aunt that doesn't probably
- 00:05:01not we're going to repeat
- 00:05:04so that's it i mean it's better than
- 00:05:06nothing but
- 00:05:08we might have some disadvantages when it
- 00:05:10comes to our ability to defend ourselves
- 00:05:13slightly
- 00:05:15and at this point
- 00:05:17some of them
- 00:05:19still say i want to shut it down anyway
- 00:05:22this discussion this even this picture
- 00:05:24doesn't move them
- 00:05:25so at this point comes
- 00:05:27one of the most magnificent features i
- 00:05:30have from tronning microsoft it is
- 00:05:32something that revelation
- 00:05:35revitalizes me so i'm to refresh it it
- 00:05:37gives me so much and it's it's the
- 00:05:39one of the absolutely most awesome
- 00:05:41features for me with microsoft i can say
- 00:05:44sorry not supported
- 00:05:47before that i would like to i need to
- 00:05:49find some blog posts do some
- 00:05:51interpretation from the powershell team
- 00:05:52tell them it's a bad idea now i can say
- 00:05:54yeah you can try to do that but it is
- 00:05:56not supported every machine you shut
- 00:05:58down powershell on which you can
- 00:06:00but every machine you shut down is out
- 00:06:02of support
- 00:06:04there's a very simple reason with that
- 00:06:06our entire windows operating system team
- 00:06:08only tests their operating system with
- 00:06:10powershell turned on the scenario of it
- 00:06:12being turned off as not being tested
- 00:06:14and
- 00:06:15things would go wrong i did test do the
- 00:06:17testing because all of the maintenance
- 00:06:19tasks are running powershell so if you
- 00:06:22disable it your server is going to start
- 00:06:24developing problems
- 00:06:27okay at that point actually i usually
- 00:06:29win if i don't if i don't win the
- 00:06:31argument with that then i kind of say
- 00:06:33okay then why are you raising support
- 00:06:35ticket of microsoft
- 00:06:36if you're not gonna care about what we
- 00:06:38support
- 00:06:39um yeah
- 00:06:41so what do you do next
- 00:06:43now there's there's one myth that comes
- 00:06:46in right next because that is something
- 00:06:47people are sure about
- 00:06:48okay if we can't shut it down let's go
- 00:06:51with execution policy
- 00:06:56a common very common confusion is that
- 00:06:58people actually believe execution policy
- 00:07:00is a security feature it is not it has
- 00:07:02never been it was never designed as a
- 00:07:04security feature and there's this nice
- 00:07:06blog post 15 ways to circumvent the
- 00:07:08execution policy it's great
- 00:07:12what is the execution policy
- 00:07:14it was designed back in the days of 2008
- 00:07:18where
- 00:07:19we thought hey there's this internet
- 00:07:21thing admins sometimes do stupid things
- 00:07:24and we want them to think again if they
- 00:07:26just download a random script and try
- 00:07:28running it and they hope it solves their
- 00:07:29problem
- 00:07:31which
- 00:07:33execution policy surprisingly enough did
- 00:07:35not work very well out
- 00:07:37as reality moved on what really happened
- 00:07:40is that all of the code on the internet
- 00:07:42is being posted on blog posts and github
- 00:07:44and we just copy paste the content in a
- 00:07:46local text file and the execution policy
- 00:07:48doesn't realize it's a script from the
- 00:07:50internet
- 00:07:52uh
- 00:07:53yeah and if you want to block everything
- 00:07:54well who can work if we do literally
- 00:07:56block everything
- 00:07:58it still has its use if you're trying to
- 00:08:01implement code signing in your
- 00:08:02organization because you can tell only
- 00:08:05code science scripts are allowed to run
- 00:08:07and with that you can kind of bully your
- 00:08:08admins into designing the script and not
- 00:08:11working around the process they can
- 00:08:13still do so but for the admin it's
- 00:08:16annoying
- 00:08:17it's it's never stopped an attacker but
- 00:08:19admins will probably kind of follow the
- 00:08:21path of least resistance and with that
- 00:08:23code setting might be the path of least
- 00:08:25resistance
- 00:08:29so if that's not the solution
- 00:08:31what then can we do
- 00:08:35well for the first thing we can manage
- 00:08:38what powershell versions we have because
- 00:08:39all of her nice and shiny security
- 00:08:41features don't work if the attacker is
- 00:08:43using a powershell version that is out
- 00:08:45of date and doesn't have those shiny and
- 00:08:46new features
- 00:08:48okay not so new anymore admittedly
- 00:08:53yeah
- 00:08:54we also have this one thing about being
- 00:08:56us needing to prevent the execute the
- 00:08:59use of older powershell versions
- 00:09:01um
- 00:09:03question to the audience who of you has
- 00:09:05made sure that in your environment
- 00:09:07older versions of powershell are
- 00:09:09uninstalled that they are no longer on
- 00:09:10the machine
- 00:09:14now
- 00:09:16yes everything older than 5.1
- 00:09:19now
- 00:09:19especially powershell version two you
- 00:09:21get uninstall the feature you make sure
- 00:09:22it's gone and you're safe right
- 00:09:25no
- 00:09:27yeah we'll be coming back to that but
- 00:09:29you need a different way to disable it
- 00:09:31we'll be looking at that
- 00:09:33we control what code is being executed
- 00:09:36and at the best way that we can do we
- 00:09:38will look at how can we harden our
- 00:09:40remoting
- 00:09:42and at the same time get rid of some of
- 00:09:44the myths that swirl around what you
- 00:09:47should be doing there and what's the
- 00:09:48actual effect of doing that because
- 00:09:50there are some guidances and myths
- 00:09:52around for example requiring https for
- 00:09:55remoting
- 00:09:56looking at that and finally um
- 00:09:59remember how i said that you should be
- 00:10:01thanking attackers for using powershell
- 00:10:03that's because they tell us what they're
- 00:10:04doing but we need to well kind of enable
- 00:10:07that and look at it which is where
- 00:10:09logging comes in
- 00:10:12okay
- 00:10:13chapter one
- 00:10:14powershell versions
- 00:10:16if you've got an older version in
- 00:10:17windows 10 and 2016 you can update that
- 00:10:19use windows management framework
- 00:10:22supported for everything other than if
- 00:10:23you're running exchange 2016 on 2012 r2
- 00:10:26operating system
- 00:10:29for version for powershell core the new
- 00:10:31shiny powershell version
- 00:10:33there is something we recently have
- 00:10:35managed
- 00:10:37and if you remember from day one the
- 00:10:39night slides of powershell consumption
- 00:10:41going through the roof with additional
- 00:10:43runs uh operations being triggered i'm
- 00:10:45fairly certain that integration into the
- 00:10:48microsoft update cycle
- 00:10:50is the main reason we have that search
- 00:10:52of that you can literally deploy it
- 00:10:55using whatever package manager you use
- 00:10:57sccm
- 00:11:00and get updates through wsus or just
- 00:11:03straight microsoft update
- 00:11:06there's one gotcha at the moment
- 00:11:09and that as we only support that for 64
- 00:11:12bits
- 00:11:13powershell not for the x86 or 32bits
- 00:11:15option you've got a question
- 00:11:19okay
- 00:11:21so with that we can make sure we also
- 00:11:23don't accidentally drop out of support
- 00:11:25for a
- 00:11:27powershell core versions
- 00:11:29so that's nice
- 00:11:35i've got that so
- 00:11:38for that i'm i hope you forgive me for
- 00:11:40not doing a demo for how to update your
- 00:11:41powershell
- 00:11:44control code execution how can we
- 00:11:47control what is being run
- 00:11:49traditionally we have an approach for
- 00:11:52that and it's called called application
- 00:11:54whitelisting
- 00:11:56we use app locker windows defender
- 00:11:58application controller whatever it's
- 00:12:00being called today i mean another
- 00:12:01renaming thing for microsoft and i
- 00:12:03didn't bother to look it up it might be
- 00:12:05out of date tomorrow soon
- 00:12:07um
- 00:12:09we can white list applications
- 00:12:12and that is where the main problem comes
- 00:12:15from when you we're talking about
- 00:12:16blocking scripting engines because the
- 00:12:18application happens to be powershell.exe
- 00:12:21or maybe
- 00:12:23pwsh.exe
- 00:12:27um or maybe not pad.exe
- 00:12:30by the way if you catch somebody around
- 00:12:32powershell and notepad you probably have
- 00:12:34a problem in your
- 00:12:36environment and yes i have had that
- 00:12:39happen
- 00:12:40um the key thing that we need to
- 00:12:42remember is that actually powershell
- 00:12:44lives in
- 00:12:45system.management.automation.dll
- 00:12:49and you can inject it into any any
- 00:12:52process and run powershell whether
- 00:12:54benignly or
- 00:12:56maliciously
- 00:12:58which by the way brings us back to you
- 00:13:00uninstalling powershell version 2 on the
- 00:13:03boxes has no effect
- 00:13:05because the attacker can you can just
- 00:13:07copy paste the perfectly legally signed
- 00:13:10by microsoft version of
- 00:13:13system.management.automation.dll in
- 00:13:14version 2
- 00:13:15and run a script there
- 00:13:18so
- 00:13:19what we need to do
- 00:13:20is uh you want to
- 00:13:22actually block all the versions of
- 00:13:24powershell
- 00:13:25is you need to block the binary which
- 00:13:27you can do with a publisher rule because
- 00:13:29it is signed by microsoft so you're
- 00:13:30blocking
- 00:13:31system.management.automation.dll the
- 00:13:33product
- 00:13:34signed by microsoft with the following
- 00:13:36version or lower
- 00:13:38that's how you can actually prevent the
- 00:13:40attacker from shipping their own
- 00:13:41versions
- 00:13:44so
- 00:13:45we don't actually have a process that we
- 00:13:47are trying to block you're trying to
- 00:13:48block the individual file the process is
- 00:13:50executing and
- 00:13:52a file we're trying to actually be
- 00:13:54executing
- 00:13:55now
- 00:13:56not so much
- 00:13:58i can
- 00:13:59do
- 00:14:00for example just co types my code on the
- 00:14:03console i mean most of us do this most
- 00:14:05of our work days
- 00:14:07i can literally paste an entire script
- 00:14:09into the console
- 00:14:12i can have it as a start parameter in
- 00:14:14powershell so there's no in a file i can
- 00:14:15just
- 00:14:16encode it command and provide a thousand
- 00:14:18lines of code as a start parameter
- 00:14:20or i could spin up
- 00:14:23system.management.automation.dll in
- 00:14:24my.net application
- 00:14:26and um yeah load the code straight into
- 00:14:28memory there
- 00:14:30so in many cases
- 00:14:33we don't have a file
- 00:14:35and of that file based blocking is added
- 00:14:37that end
- 00:14:39it's it's never going to work
- 00:14:42we had application whitelisting support
- 00:14:44for powershell in powershell version 4
- 00:14:47already
- 00:14:48and if you did that there it would block
- 00:14:50the script execution
- 00:14:52but it would never provide the
- 00:14:54protection by just you know reading the
- 00:14:56file into memory and then executing the
- 00:14:58text as code
- 00:15:00so
- 00:15:01in powershell version 4 that didn't
- 00:15:02really work as we had hoped for
- 00:15:04and we have the same problem for
- 00:15:06antivirus software not just for how can
- 00:15:08we prevent our execution but how can we
- 00:15:10detect malware if you don't have a file
- 00:15:13to scan and you've got file signatures
- 00:15:14on your antivirus the antivirus is not
- 00:15:16going to have so much fun and most
- 00:15:19modern attacking for example fun x
- 00:15:22control execution scheme the client code
- 00:15:24is benign that they are executing in the
- 00:15:26office micro and they would receive
- 00:15:27their actual pay code using dns queries
- 00:15:30by looking up text record of the actual
- 00:15:32malware code
- 00:15:33who amongst us is filtering dns records
- 00:15:38yeah
- 00:15:39so what we added is something called the
- 00:15:41anti-malware scan interface we had a
- 00:15:44great talk on that i think it was
- 00:15:45yesterday
- 00:15:47if you didn't attend that there's a
- 00:15:48recording i can strongly recommend that
- 00:15:50if you want to see how exactly it works
- 00:15:52but what it really happens behind the
- 00:15:54scene is you're submitting all the code
- 00:15:57and any malware anti-malware service uh
- 00:16:00antivirus can scan for it and tell you
- 00:16:02that this malware don't execute it so
- 00:16:04for some reason defender for example
- 00:16:07is quite prejudiced against invoke many
- 00:16:09cuts
- 00:16:10i wonder why
- 00:16:13now
- 00:16:13there's two caveats about
- 00:16:16benefiting from amsi or the mother scan
- 00:16:19interface and that is first of all it
- 00:16:21has a strict operating system
- 00:16:23requirement
- 00:16:24even if you install powershell 5.1 on
- 00:16:27your old servers they don't get mz
- 00:16:29because your old clients don't get mc
- 00:16:31this is an operating system feature
- 00:16:33and the other one is your antivirus
- 00:16:34needs to support this if you have
- 00:16:36defender yes it works
- 00:16:38for some of the others you will need to
- 00:16:40check with your vendor
- 00:16:42do they support it do you need to do
- 00:16:43anything to enable it i know at least
- 00:16:45one software vendor that supports it but
- 00:16:47you need to check one checkbox otherwise
- 00:16:48you don't get it
- 00:16:51yeah so that is how we can detect
- 00:16:54fairly reliably malicious actors get
- 00:16:57alerts get your
- 00:16:59malware detection in your antivirus
- 00:17:01console that's great
- 00:17:03but at this point the attacker was
- 00:17:05possibly still able to run some code i
- 00:17:07mean we might have been able to block it
- 00:17:08but
- 00:17:09what if the attacker actually invented
- 00:17:11their own virus and you hit by zero day
- 00:17:13and the signature just doesn't exist yet
- 00:17:16the application whitelisting approach is
- 00:17:19hey only the thing that i'm allowing to
- 00:17:21run is allowed to run
- 00:17:23so that it has a great benefit we don't
- 00:17:25need to know the actor as long as we
- 00:17:27know you're not one of us
- 00:17:29and
- 00:17:30that would be great if you had it in
- 00:17:32powershell but the
- 00:17:34problems we're not filibuster you can
- 00:17:36only run this file approach doesn't work
- 00:17:38so what can we do
- 00:17:39we have something called constraint
- 00:17:41language mode and if you have an engage
- 00:17:44application whitelisting of any kind
- 00:17:46all powershell code will be run under
- 00:17:49this mode
- 00:17:50applocker is an option it's an easy to
- 00:17:52deploy faster faster go option if you
- 00:17:55want to a full security feature rather
- 00:17:58than just defense and depth go for
- 00:18:00windows defender application control or
- 00:18:02equivalent things that actually
- 00:18:04work at the kernel level properly
- 00:18:08but applocker is something you can
- 00:18:09deploy in a few minutes and get some
- 00:18:11protection out of it
- 00:18:14constraint language mode that is the
- 00:18:16main feature that we have what does it
- 00:18:18say if our code is not trusted
- 00:18:21you don't get all of the things power
- 00:18:23can do
- 00:18:25for
- 00:18:26example you can
- 00:18:28not call any net methods most properties
- 00:18:31are read only on objects
- 00:18:33some commands may not work at all
- 00:18:36for example there's this nice command
- 00:18:38called enter ps host process
- 00:18:40that allows you to
- 00:18:42inject yourself into the powershell
- 00:18:43console of your co-worker on the machine
- 00:18:46and then execute code in the context of
- 00:18:48your co-worker who might be kind of
- 00:18:49pieced if you you know
- 00:18:51a domain admins group or take a global
- 00:18:54admin in your tenant in his name but
- 00:18:55with your ideas behind that
- 00:18:58and that doesn't work anymore if you
- 00:19:00when you have that enabled
- 00:19:02you can't do powershell classes you
- 00:19:03can't do a tab you don't have any access
- 00:19:05direct access to the windows apis
- 00:19:08we just can on all the known malware
- 00:19:11that we have in our defender database
- 00:19:14that uses powershell
- 00:19:15and more than 99.9 of all attacker
- 00:19:19scripts would not run in this
- 00:19:22mode yes
- 00:19:26yes
- 00:19:28powershell 7 does also support
- 00:19:30constraint language mode it applies the
- 00:19:32same rules
- 00:19:34and the same considerations
- 00:19:37so if turning on application white
- 00:19:39listing actually enables constrained
- 00:19:41language mode what about our own code i
- 00:19:44mean yes it's nice you're blocking the
- 00:19:45attacker but we probably don't want to
- 00:19:49you know block the official admin code
- 00:19:54there are
- 00:19:56some
- 00:19:56ways to solve the problem for example
- 00:19:58you could explicitly white list any
- 00:20:00modules stored on the c programs
- 00:20:04program files
- 00:20:05windows powershell modules pathwhite
- 00:20:07listing any module that you're right
- 00:20:09listing or if you got code signing
- 00:20:11implemented strongly recommended you
- 00:20:13could whitelist your signer certificate
- 00:20:15if you do that
- 00:20:17any code that is trusted
- 00:20:19is
- 00:20:20allowed to run uninhibited
- 00:20:23of course that also means you need to
- 00:20:25make sure that an attacker cannot use
- 00:20:27your trusted code to run turn untrusted
- 00:20:30code into trusted code
- 00:20:32for example if you're using invoke
- 00:20:33expression in your own trusted code and
- 00:20:35taking the input and invoking it you
- 00:20:38probably have the powershell equivalent
- 00:20:39of a sql instruction
- 00:20:42not always great
- 00:20:44yeah
- 00:20:46you can also affect and that is the main
- 00:20:48deployment trick to get it deployed
- 00:20:50swiftly you can exclude elevated
- 00:20:53processors from this
- 00:20:55so it only applies to regular
- 00:20:58consoles
- 00:20:59very
- 00:21:00handy and this is the next one if you're
- 00:21:03writing powershell modules even if
- 00:21:05you're wise listing it if you've got
- 00:21:07this nice
- 00:21:08functions to export wildcard thing going
- 00:21:11on because it's convenient because it's
- 00:21:12easy
- 00:21:14you will not have a great experience
- 00:21:15because whitelisted or not powershell is
- 00:21:17going to tell you no
- 00:21:24in order to ensure integrity you cannot
- 00:21:26dot source a trusted script in an
- 00:21:28untrusted context which by the way means
- 00:21:30you can never white list your powershell
- 00:21:32profile
- 00:21:33never
- 00:21:34because the profile is being dot sourced
- 00:21:36into the powershell process as it starts
- 00:21:39what you would do instead is you put
- 00:21:41your profile as a content as a
- 00:21:43powershell module that you whitelist and
- 00:21:45then in your untrusted profile you
- 00:21:46import the module
- 00:21:51all right enough talking
- 00:21:55let's
- 00:21:56take a look at how we do that now the
- 00:21:58first thing we need is something that
- 00:22:01actually
- 00:22:02gives us a level of uh
- 00:22:05opera operability when we define the
- 00:22:07rules we don't want to handcraft
- 00:22:09everything and there is a tool by a
- 00:22:12certain guy called aaron margosis
- 00:22:14called aaron locker
- 00:22:16it's moved he's moved on from microsoft
- 00:22:18was a security architect previously
- 00:22:21and
- 00:22:22well
- 00:22:24he did a scanning tool that will
- 00:22:28take a reference machine and scan it for
- 00:22:33configuration and then generate a
- 00:22:36policy set to
- 00:22:37well
- 00:22:39secure a machine including powershell
- 00:22:40rules
- 00:22:43for that
- 00:22:45let's
- 00:22:47start a powerful process in the folder
- 00:22:51and all we need from that
- 00:22:53solution is the
- 00:22:54create policies command
- 00:23:03it is now scanning the machine and
- 00:23:05generating proper
- 00:23:14damn it
- 00:23:15the demo god still got me i really
- 00:23:17should have i should not have taunted
- 00:23:18them
- 00:23:20do we have that lying around
- 00:23:24i don't so i'm going to um
- 00:23:27swiftly steal that
- 00:23:30from my most trusted automated lab
- 00:23:32solution which in lab sources has
- 00:23:35tools this internals and there's access
- 00:23:38check right there
- 00:23:40thank you raymond
- 00:23:44so let's try this again with less red
- 00:23:46stuff
- 00:23:49okay um
- 00:23:51when you do path white list and we do
- 00:23:53have a habit of like you know see
- 00:23:54windows and the program files are going
- 00:23:55to be safe right
- 00:23:58actually in undersea windows there are
- 00:23:59quite a few folders users are allowed to
- 00:24:01write and we need to have an exemption
- 00:24:03for that because if you just whitelist
- 00:24:04windows folder
- 00:24:06you could for example use the the folder
- 00:24:08used for spooler spooling tasks to just
- 00:24:11create a file there and run it from
- 00:24:12there and it's whitelisted
- 00:24:14not a good choice
- 00:24:16so we have that now we need a gpmc dot
- 00:24:20msc
- 00:24:22and let's say i want my
- 00:24:26servers to be subject to
- 00:24:29um
- 00:24:38yes i know this is only a link and i'm
- 00:24:40going to edit it anyway
- 00:24:44edit
- 00:24:47[Music]
- 00:24:49where the hell was that
- 00:24:51under security settings
- 00:24:53we have
- 00:24:55lots of information and one of them is
- 00:24:57the application control policies which
- 00:25:00is applocker
- 00:25:02for that we can now import a policy file
- 00:25:04if we have one at hand
- 00:25:07which we have here in the outputs we
- 00:25:09have
- 00:25:11two policies
- 00:25:12one of them is audit the others enforce
- 00:25:14if you use the audit policy
- 00:25:16you get warnings in the event lock but
- 00:25:18it does not actually enforce anything so
- 00:25:20if you want like get your feet wet see
- 00:25:22what would happen if i turn this on you
- 00:25:24use the audit policy and you just get
- 00:25:26warnings and you can plan for the
- 00:25:28migration if which somebody would
- 00:25:29actually be stopped by that
- 00:25:34okay we need to import a policy
- 00:25:38i'm going to go to that folder grab the
- 00:25:42now let's go with enforcement i mean
- 00:25:44what could possibly go wrong
- 00:25:47yep i want to import that
- 00:25:49none were removed 95 for edit and we now
- 00:25:52have applocker policies
- 00:25:54for example we have now at the seller
- 00:25:55powershell version two rule in here
- 00:25:57pre-configured for us
- 00:25:59which when we look inside is a publisher
- 00:26:02rule with the
- 00:26:03publisher product
- 00:26:05name
- 00:26:07file name and the specific version we're
- 00:26:09requiring requiring
- 00:26:12and if that all older versions of
- 00:26:14powershell are blocked whether it's the
- 00:26:15built in one or somebody ships it in
- 00:26:18piece of warning if you're supporting
- 00:26:20sql servers they've got a powerful agent
- 00:26:22and depending on the sql server agent
- 00:26:24that powershell version is lower than
- 00:26:265.1
- 00:26:28so you might accidentally block a sql
- 00:26:31server automation
- 00:26:36all right with all that we now have
- 00:26:38amongst other things script rules with
- 00:26:41the various paths that are explicitly
- 00:26:43white listed
- 00:26:44including the windows folder which has
- 00:26:46exceptions for all of the files that
- 00:26:48actually users can write to
- 00:26:50freshly scanned if you've got a modified
- 00:26:52device
- 00:26:53it's going to pick that up so you pick
- 00:26:54one representative
- 00:26:56machine and that's it
- 00:26:59the other thing we need to do is enable
- 00:27:01one certain service and make sure it's
- 00:27:03running
- 00:27:06where do i need to go for that
- 00:27:15not that it's in control panel settings
- 00:27:17services
- 00:27:20new
- 00:27:21service and the thing service that we
- 00:27:23need is the app id service
- 00:27:26which absolutely should be started
- 00:27:29and it needs to be automatic
- 00:27:32if you don't run that service that is
- 00:27:34what actually passes through the
- 00:27:35applocker rule to the system and
- 00:27:37enforces it
- 00:27:38it doesn't work which by the way is the
- 00:27:40absolute proof in case you're wondering
- 00:27:41that app locker is not um
- 00:27:44not a security feature but a defense
- 00:27:45in-depth feature because anybody who
- 00:27:47gains local admin can simply turn off
- 00:27:49that service
- 00:27:51or inject their own wireless
- 00:27:54whitelist everything rule and
- 00:27:57keep the servers running to avoid the
- 00:27:58signals
- 00:28:03all right
- 00:28:05that's sad
- 00:28:08how does execution policy at the
- 00:28:10constraint language would actually limit
- 00:28:12our coding
- 00:28:16system
- 00:28:17less typos threat and it actually might
- 00:28:19work
- 00:28:20it's still optimistic but
- 00:28:24maybe i can actually yes
- 00:28:28so let's resume resolve localhost and
- 00:28:32see what it's going to do it works just
- 00:28:34fine if you want to check your current
- 00:28:37language mode you can do that with the
- 00:28:39dollar execution context
- 00:28:41session state
- 00:28:42language mode so i'm in full language
- 00:28:45mode i can do whatever i want on the
- 00:28:47machine
- 00:28:48as long as i've got the necessary
- 00:28:49privileges actually but the language
- 00:28:51features are not disabled in any way so
- 00:28:54i'm just going to
- 00:28:55for this demo because i
- 00:28:58don't want to actually wait for a group
- 00:29:00policy application to properly work the
- 00:29:02service and everything i can actually
- 00:29:04enforce constrained language mode if i
- 00:29:06actually
- 00:29:08don't forget the language part
- 00:29:10no what did i mess up that yeah without
- 00:29:13the mode
- 00:29:16all right we are now
- 00:29:20locked down
- 00:29:21and if i now try to do the result thing
- 00:29:24that's the error that i get
- 00:29:32yeah we're locked on and we locked i
- 00:29:34flocked on the process and every new
- 00:29:35process that our start
- 00:29:37is going to be affected by this
- 00:29:39as long
- 00:29:40as long
- 00:29:41as the user's temp folder is locked down
- 00:29:45by the policy if you whitelist the temp
- 00:29:47folder
- 00:29:48the console will not go into constraint
- 00:29:50language mode
- 00:29:52so let's fix that
- 00:29:58code signing um
- 00:30:00would go around that as long as the
- 00:30:02policy is applied so if i had the gpu
- 00:30:04update applied
- 00:30:05id service running and everything i
- 00:30:08tried to run the file the file would not
- 00:30:10be in constraint language mode if i have
- 00:30:12that signed by a trusted certificate
- 00:30:14that is whitelisted by a rule it's not
- 00:30:16enough to just be trusted it needs to be
- 00:30:18whitelisted
- 00:30:21so let's go back to full language
- 00:30:26uh yeah
- 00:30:30no
- 00:30:31constraint language mode i can't write
- 00:30:32to any properties anymore so
- 00:30:34bootstrapping me back into full language
- 00:30:36mode is
- 00:30:37a losing game
- 00:30:41so let's kill the console and the reason
- 00:30:43i actually
- 00:30:44try to not lock myself down is because i
- 00:30:47need to run a few more samples
- 00:30:50let's say we are planning this whole
- 00:30:51thing out we've talking with teams and
- 00:30:54they are kind of wondering will our code
- 00:30:56be affected by constrained language mode
- 00:30:58i mean you've got a huge code base and
- 00:31:00which of these scripts might be at risk
- 00:31:02you can't enable the auditing and see
- 00:31:04the error events happen
- 00:31:06but wouldn't that be kind of useful to
- 00:31:08have a scanner to do this for you
- 00:31:11so let's
- 00:31:13take a look at this nice script so
- 00:31:15a script i wrote for
- 00:31:17figuring out
- 00:31:18uh a d delegation and writing the
- 00:31:21results somewhere this is
- 00:31:23usual working script
- 00:31:24let's see how that would be affected
- 00:31:33i need this inner size you folks can
- 00:31:35actually follow and i think size 2 14 is
- 00:31:37not the answer to that
- 00:31:41okay it's not going to work here but
- 00:31:43there's a module called ps module
- 00:31:45development
- 00:31:47it's my personal development um
- 00:31:51toolkit templating refactoring
- 00:31:54dot net searching restarting my console
- 00:31:56as admin whatever i really need and it
- 00:32:00also
- 00:32:01includes a
- 00:32:02certain command
- 00:32:04okay now that doesn't work out
- 00:32:07um it has a test
- 00:32:09psmd
- 00:32:11clm compact controllability
- 00:32:14[Music]
- 00:32:16clm compatibility command
- 00:32:21and with that i can specify the path and
- 00:32:23it's complaining about every single
- 00:32:24thing that's going to go wrong
- 00:32:27if you run this in
- 00:32:28non-compact mode
- 00:32:35all right uh damn it uh
- 00:32:39totally hitting this getting cut down by
- 00:32:43having less time for the whole thing uh
- 00:32:45i think ready right here sorry about the
- 00:32:47scheduling issues i'm going to have to
- 00:32:49skip a few of the next demons because i
- 00:32:51need to cover a few more things you
- 00:32:52probably have some questions and we only
- 00:32:54have so much time so i have to skip the
- 00:32:56other demos for that
- 00:32:59when we try to configure remoting how
- 00:33:02can we make our system safe
- 00:33:06the group policy settings are clearly
- 00:33:07separated between server and client that
- 00:33:10is not the operating system reference
- 00:33:12the client is the source of the
- 00:33:13connection the server is the recipient
- 00:33:15of the connection no matter what this
- 00:33:18does
- 00:33:19we can configure where we want to accept
- 00:33:21accessions from using the firewall
- 00:33:24there's a setting enable powershell
- 00:33:26remoting and then you can like specify
- 00:33:28an rp range this is not where you're
- 00:33:31accepting sessions from this is a filter
- 00:33:34to your local network adapters on which
- 00:33:36network adapter do you want to receive
- 00:33:38the connection on
- 00:33:40so that is why wildcard is the usual
- 00:33:42recommendation there because it just
- 00:33:43means every network adapter and that's
- 00:33:45it
- 00:33:46you want to filter that if you for
- 00:33:47example you've got a machine that has a
- 00:33:49public interface and a management
- 00:33:50interface and you only want to accept
- 00:33:52connections from the management
- 00:33:53interface
- 00:33:55and we have authentication options
- 00:33:58that's like for example do you allow
- 00:34:00basic authentication
- 00:34:03the basic authentication thing is one of
- 00:34:05the classic myths that we encounter
- 00:34:08specifically for exchange online admins
- 00:34:10and
- 00:34:11people that have to go work with the
- 00:34:14security compliance center module
- 00:34:16because if you wanted to administrate
- 00:34:19exchange online you would be forced to
- 00:34:21enable basic authentication for the
- 00:34:23client
- 00:34:25now
- 00:34:26when when a security admin hears basic
- 00:34:29authentication that's like of are you
- 00:34:31are you trying to
- 00:34:33ritually sacrifice my child are you what
- 00:34:35the hell are you trying to do your basic
- 00:34:37authentication that was in the 90s maybe
- 00:34:40why would you do basic authentication
- 00:34:42um
- 00:34:44well
- 00:34:45turns out that uh the winner m service
- 00:34:48that is operating the connection
- 00:34:51has no concept of modern alpha
- 00:34:54so if you put an enable basic
- 00:34:56authentication put some network trace in
- 00:34:57there what exchange online module and
- 00:34:59the others
- 00:35:00did
- 00:35:01is they would first do modern off
- 00:35:03against azure id and the basic
- 00:35:05authentication would actually be the
- 00:35:06token
- 00:35:07so you're doing modern authentication
- 00:35:09service just has no way to detect that
- 00:35:13so that's why i did that there is one
- 00:35:16important thing for all of the security
- 00:35:18folks out there
- 00:35:19in powershell you cannot force anybody
- 00:35:22to do basic authentication from the
- 00:35:23server side you can't trick them into
- 00:35:25your downgrade attack to use a less
- 00:35:26secure protocol to send an unencrypted
- 00:35:29password you can't do that the user
- 00:35:32needs to explicitly request that
- 00:35:35so allowing from the client side the
- 00:35:37basic authentication does not actually
- 00:35:39incur any additional risk unless you've
- 00:35:40got somebody who's trying to force it
- 00:35:45yeah
- 00:35:46you can also mess with the network
- 00:35:48settings for example you can tell that
- 00:35:50you must
- 00:35:51use https for your connection
- 00:35:54if you do that
- 00:35:56you get absolute security obviously
- 00:35:58because you know hdp by default so
- 00:36:00powershell is working unencrypted
- 00:36:04now we just don't do transport level
- 00:36:05encryption
- 00:36:06it's if you've got a default domain
- 00:36:08you've got is 256 through camera
- 00:36:10software of crabbers communication so we
- 00:36:12do encrypt the packets
- 00:36:14the only
- 00:36:16real safety you get when you use enable
- 00:36:17https is if somebody has a reason to use
- 00:36:20ntlm authentication because an ntlm the
- 00:36:23client does not authenticate the server
- 00:36:26and that you can do with the certificate
- 00:36:28but that's the only security you get
- 00:36:30here so
- 00:36:31it's only relevant if you still use ntlm
- 00:36:33authentication for something
- 00:36:35and a big surprise managing the
- 00:36:38certificates is kind of annoying because
- 00:36:40the auto enrollment and auto registering
- 00:36:42in winrar and this doesn't really help
- 00:36:43me so you have to manage that as well
- 00:36:45so you get administrative overhead the
- 00:36:48security is gain is very situational
- 00:36:53yeah i could show you the configuration
- 00:36:56option options and how that i will add
- 00:36:57the exported policies on all of the
- 00:37:00settings that you're seeing in the
- 00:37:01materials when it's on the github for
- 00:37:03looking them up but i think um seeing me
- 00:37:05operate the crew policy console is not
- 00:37:07going to add much to the session
- 00:37:10so we're skipping that
- 00:37:12which leaves us with logging
- 00:37:15in powershell we have three separate
- 00:37:17logging options we can do transcript
- 00:37:19logging which we can do since the age of
- 00:37:21powershell 2. we've got module logging
- 00:37:23since the age of powershell 4 and we
- 00:37:26have script block logging which we have
- 00:37:27since powershell 5.
- 00:37:29transcript has the nice advantage that
- 00:37:32it actually shows also what have been on
- 00:37:33screen which is great for debugging
- 00:37:35purposes it's not so great from a
- 00:37:36security perspective because a you need
- 00:37:39to do log rotation b it's clear text
- 00:37:42c somebody might have accidentally
- 00:37:44leaked something sensitive on the
- 00:37:45console screen which previously was not
- 00:37:47noticed but now is in clear text
- 00:37:49unencrypted text file on the screen
- 00:37:51or you might have some privacy concerns
- 00:37:53if you've got a user actually using
- 00:37:54powershell for its online banking i mean
- 00:37:56i haven't seen that but i wouldn't
- 00:37:58exclude the possibility
- 00:38:01um yeah so a script transcript blogging
- 00:38:03i strongly
- 00:38:05advise against that as a global security
- 00:38:07feature you can do that for your actual
- 00:38:09logging in a script
- 00:38:10i would like to talk to you about ps
- 00:38:12framework if you do
- 00:38:14but
- 00:38:15yeah
- 00:38:16module logging is
- 00:38:18well the lesser brother of script
- 00:38:20loggers i really just recommend going
- 00:38:21with script block logging which will
- 00:38:23give you the same information in the
- 00:38:25event log as the mz gets so you get a
- 00:38:28full script block that's every code
- 00:38:29that's being run
- 00:38:31if you enable that you still need to
- 00:38:33ship the lock somewhere so
- 00:38:35yeah
- 00:38:36handling that is a bit of the hard part
- 00:38:38it's
- 00:38:40you still need to analyze that and there
- 00:38:42is
- 00:38:43not all that much aid that you can get
- 00:38:45from microsoft from that so far
- 00:38:47so we just say hey do the logging and do
- 00:38:49whatever you think you need to do
- 00:38:51detection afterwards i'm currently
- 00:38:53working on a module to help you with
- 00:38:55that to
- 00:38:56help analyze what script is running on
- 00:38:58which machines you can do pattern
- 00:38:59detection for example the maintenance
- 00:39:01script that every client is running
- 00:39:03and so you can see um can identify known
- 00:39:06scripts and identify anon script and
- 00:39:08then start investigating on that
- 00:39:10but that's not quite done but i will
- 00:39:12definitely be announcing that on twitter
- 00:39:14once it's ready
- 00:39:17yeah there are a few other things we can
- 00:39:19do just a quick checklist i'm definitely
- 00:39:21not going to demo that here
- 00:39:23because that is entirely separate calls
- 00:39:25at talks to have there's another two
- 00:39:28hours a session just on how to do
- 00:39:30properly released thing but you want to
- 00:39:32look into how to
- 00:39:34imple release your own code and how to
- 00:39:36accept foreign code
- 00:39:39so you can actually safely use public
- 00:39:41modules
- 00:39:42which includes code signing and internal
- 00:39:45source control
- 00:39:46and if you've never used it there's a
- 00:39:48just enough administration it's a
- 00:39:50powershell remoting feature that allows
- 00:39:52you to delegate individual processes
- 00:39:54rather than control over the entire
- 00:39:56system
- 00:39:57scenario help desk terminal servers help
- 00:40:00this with gi you could authorize the
- 00:40:02help desk user to
- 00:40:04send a message to the user figure out
- 00:40:05who's logged on and turn off sessions
- 00:40:08that are hanging but not anything else
- 00:40:10if you don't use chair you basically
- 00:40:12have to construct your own constructor
- 00:40:14give them local admin on each terminal
- 00:40:16server which let's be honest i don't
- 00:40:18want to do with help desk users mostly
- 00:40:22final slide then you're done with the
- 00:40:24powerpoint mess
- 00:40:26sorry about that
- 00:40:27about the rush um now that we've got a
- 00:40:30lot of features but how do we actually
- 00:40:32implement it how do we go now go about
- 00:40:34bringing this into reality is there's a
- 00:40:36recommendation there i strongly
- 00:40:39recommend that you nail down the
- 00:40:41remoting
- 00:40:42just uh if you've got um just you know
- 00:40:45only allow powershell remote connection
- 00:40:47from an admin network because users
- 00:40:49really don't have a reason to connect to
- 00:40:50each other with partial remoting
- 00:40:52that would solve a lot of the lateral
- 00:40:55movement from client to client the
- 00:40:57hardship here is you of course need to
- 00:40:58have a network an administrative network
- 00:41:01to identify
- 00:41:03which might be not quite as trivial
- 00:41:06process than just
- 00:41:09setting up some firewall rules
- 00:41:11the other one i recommend is doing app
- 00:41:13locker in user mode so you
- 00:41:16only affect non-admin processes
- 00:41:19and deploy constraint language mode
- 00:41:22this actually can be done in five
- 00:41:23minutes and uh
- 00:41:25massively impacts what an attacker can
- 00:41:27do in the user mode on an affected
- 00:41:29client
- 00:41:30and it usually has absolutely no side
- 00:41:32effects on regular
- 00:41:34processes
- 00:41:37the logging
- 00:41:38enabling it is fast managing it and
- 00:41:41getting useful action is a pro as a
- 00:41:43process that's going to be ongoing so
- 00:41:46that's not something
- 00:41:47swiftly done over it's more something
- 00:41:48you put into as part of your
- 00:41:51risk management process
- 00:41:53and finally
- 00:41:55you want to have internal code
- 00:41:57management you want to have internal
- 00:41:59approval process for external modules
- 00:42:01you want to have a way to
- 00:42:03centralize this so you can share that
- 00:42:05with other teams so you don't have that
- 00:42:07redundancy inside of
- 00:42:10inside of your organization because it's
- 00:42:12a fairly expensive process to actually
- 00:42:15approve
- 00:42:16external code because you have to have
- 00:42:17to do the review
- 00:42:19and the last one is one i must admit
- 00:42:21i've never managed to establish fully in
- 00:42:24an environment
- 00:42:25that we have a full hard enforcement
- 00:42:28that only whitelisted code only approved
- 00:42:31code for the process only that this code
- 00:42:33signed can be used internally because
- 00:42:35that really puts requires all of the
- 00:42:38other processes to already be in place
- 00:42:41that said there is one more advice
- 00:42:44that incredibly helps with adoption as
- 00:42:47soon as you possibly can
- 00:42:49get your admins to use source control
- 00:42:52even if it's just so they have an unlike
- 00:42:55an online version of their code they
- 00:42:57have a master version that is the true
- 00:42:59copy of the script they don't even have
- 00:43:00to share that with their co-workers
- 00:43:02but a lot of the advanced workflows are
- 00:43:05only possible if you already use source
- 00:43:07control for getting a code signing
- 00:43:09pipeline for getting a proper approval
- 00:43:12process
- 00:43:13and
- 00:43:13if you'd also have to now start teaching
- 00:43:16your admins at the same time the tools
- 00:43:18needed you get a lot of internal
- 00:43:19resistance to all of the change you're
- 00:43:21forcing on them if you start them off of
- 00:43:24source control just for you know having
- 00:43:26a backup of the two having in case the
- 00:43:28client crashes having a central location
- 00:43:31that's something you can't do swiftly
- 00:43:33and they can already get used to the
- 00:43:34tools so they only have to master the
- 00:43:36new process later on
- 00:43:38otherwise i've had at least two projects
- 00:43:41basically stop at that stage simply
- 00:43:43because the admins rejected the
- 00:43:45having to master the tools in the pros
- 00:43:47and everything but because it was one
- 00:43:48large package
- 00:43:52thank you everybody um now it's a bit
- 00:43:55less time for that than i really hoped
- 00:43:57for but
- 00:43:58any questions
- 00:44:05yes
- 00:44:08can powershell 7 be updated through ws
- 00:44:11yes it can
- 00:44:13yes
- 00:44:16again only 64-bit not 32-bit
- 00:44:19yes
- 00:44:33i would do individual exemption for
- 00:44:35those
- 00:44:37the developer machines basically give
- 00:44:39them a give them a machine a virtual
- 00:44:41machine or vdi environment in a
- 00:44:43test environment where they cannot
- 00:44:44corrupt the environ organization
- 00:45:04[Music]
- 00:45:14it used to work in my lab environment
- 00:45:16right after the announcement when i
- 00:45:17tried it
- 00:45:18but um i don't know whether it's broken
- 00:45:21again in the current state
- 00:45:23i have to look that up in the i also
- 00:45:26have to
- 00:45:27set up a lab for that and iterate that
- 00:45:29through but
- 00:45:42okay how do we handle sscm clients with
- 00:45:45unsigned code
- 00:45:48the sccm client has a dedicated folder
- 00:45:51value to putting their code before
- 00:45:53executing it the script code
- 00:45:55you whitelist that path
- 00:45:56it is a path where only the system has
- 00:45:58write access to by default which you
- 00:46:00should of course be monitoring for
- 00:46:02whether somebody managed to modify that
- 00:46:04but
- 00:46:06you can do a pathfight list to solve
- 00:46:07most of those problems also to make sure
- 00:46:11you actually catch that
- 00:46:12you can also
- 00:46:15do two more things one most of the scm
- 00:46:17agent scripts are run as administrator
- 00:46:19so as long as you only do the
- 00:46:22non-admins are affected to rule
- 00:46:25those agent tasks will not be affected
- 00:46:27the second part is you could also and
- 00:46:30should do an initial
- 00:46:32audit mode and just check for whether
- 00:46:34they would be affected
- 00:46:36in the event log you see where the file
- 00:46:38would have been so you can analyze an
- 00:46:40automatic filter for
- 00:46:42warnings about applica
- 00:46:44or similar blocking them
- 00:46:46for that sccm folder path
- 00:46:50that's another way to handle the ssm
- 00:46:52client thing
- 00:46:56one more question
- 00:46:58um
- 00:47:12um that is not part of the security
- 00:47:15feature of script blog logging or
- 00:47:16anything like that it's the powershell
- 00:47:18module called ps readline which
- 00:47:20maintains an input history in your app
- 00:47:22data folder
- 00:47:24you can grab the path for that um let me
- 00:47:28do that one real quick that is
- 00:47:31fast to do
- 00:47:33so get ps
- 00:47:35read
- 00:47:38line option
- 00:47:39you can see the path where it's saving
- 00:47:41your history here
- 00:47:44it is merely your input history it tries
- 00:47:46to filter to avoid secrets
- 00:47:49but if you do like a dollar p equals
- 00:47:52quote clear text password quote you're
- 00:47:55not giving ps3 line much to work with
- 00:47:58so if you accidentally leak a secret
- 00:48:00there you might want to check that file
- 00:48:02whether it's in there you can just
- 00:48:03delete it
- 00:48:04you can also disable it by
- 00:48:07setting the history save style to none
- 00:48:12all right we are already over time and i
- 00:48:15kind of probably should
- 00:48:16vacate the place here if you quit any
- 00:48:18more follow-up question you can find me
- 00:48:20across the conference floor getting me
- 00:48:21to talk about powershell is probably
- 00:48:22going to be one of the least difficult
- 00:48:24tasks you will be facing here
- 00:48:27[Applause]
- 00:48:36[Music]
- 00:48:48you
- PowerShell
- Security
- Automation
- Microsoft
- Execution Policy
- AppLocker
- Constrained Language Mode
- Logging
- Application Whitelisting
- Cybersecurity