ばぁど・うぉっちんぐ

セキュリティに強いWeb屋。自由と春を求めて羽ばたく渡り鳥。

このブログはGoogle Analyticsを利用しています

BadStore に対して OWASP ZAP で動的検査を実施した結果

どーも。ばぁどです。 脆弱性診断を仕事としています。元Webアプリエンジニアです。 開発もできる脆弱性診断士を目指しています。

今回はやられ用のWebサイトであるBadStoreに、自動脆弱性診断ツールであるOWASP ZAPで動的に検査してみました。

OWASP ZAPの結果を貼り付けただけの雑記事です。

BadStore とは

やられ用のWebサイトです。 筆者はローカルプロキシツールであるBurpSuiteの拡張として入れました。

github.com

OWASP ZAP

脆弱性診断ツール。

www.zaproxy.org

感想

OWASP ZAPのレポートが非常に長いので、先に感想を。

自動脆弱性診断ツールは非常に便利。手動診断と比べても早く、網羅的に、人手を使わずにある程度の脆弱性を見つけてくれています。ツールごとに得意・不得意があったり、逆に手動診断でないと見つけることができない部分はあるはずなので、そういった理解を深めていきたい。

ZAP Scanning Report

Summary of Alerts

Risk Level Number of Alerts
High 6
Medium 3
Low 6
Informational 0

Alert Detail

Cross Site Scripting (Reflected)

High (Medium)

Description

Cross-site Scripting (XSS) is an attack technique that involves echoing attacker-supplied code into a user's browser instance. A browser instance can be a standard web browser client, or a browser object embedded in a software product such as the browser within WinAmp, an RSS reader, or an email client. The code itself is usually written in HTML/JavaScript, but may also extend to VBScript, ActiveX, Java, Flash, or any other browser-supported technology.

When an attacker gets a user's browser to execute his/her code, the code will run within the security context (or zone) of the hosting web site. With this level of privilege, the code has the ability to read, modify and transmit any sensitive data accessible by the browser. A Cross-site Scripted user could have his/her account hijacked (cookie theft), their browser redirected to another location, or possibly shown fraudulent content delivered by the web site they are visiting. Cross-site Scripting attacks essentially compromise the trust relationship between a user and the web site. Applications utilizing browser object instances which load content from the file system may execute code under the local machine zone allowing for system compromise.

There are three types of Cross-site Scripting attacks: non-persistent, persistent and DOM-based.

Non-persistent attacks and DOM-based attacks require a user to either visit a specially crafted link laced with malicious code, or visit a malicious web page containing a web form, which when posted to the vulnerable site, will mount the attack. Using a malicious form will oftentimes take place when the vulnerable resource only accepts HTTP POST requests. In such a case, the form can be submitted automatically, without the victim's knowledge (e.g. by using JavaScript). Upon clicking on the malicious link or submitting the malicious form, the XSS payload will get echoed back and will get interpreted by the user's browser and execute. Another technique to send almost arbitrary requests (GET and POST) is by using an embedded client, such as Adobe Flash.

Persistent attacks occur when the malicious code is submitted to a web site where it's stored for a period of time. Examples of an attacker's favorite targets often include message board posts, web mail messages, and web chat software. The unsuspecting user is not required to interact with any additional site/link (e.g. an attacker site or a malicious link sent via email), just simply view the web page containing the code.

Instances: 6

Solution

Phase: Architecture and Design

Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

Examples of libraries and frameworks that make it easier to generate properly encoded output include Microsoft's Anti-XSS library, the OWASP ESAPI Encoding module, and Apache Wicket.

Phases: Implementation; Architecture and Design

Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required encoding strategies.

For any data that will be output to another web page, especially any data that was received from external inputs, use the appropriate encoding on all non-alphanumeric characters.

Consult the XSS Prevention Cheat Sheet for more details on the types of encoding and escaping that are needed.

Phase: Architecture and Design

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.

Phase: Implementation

For every web page that is generated, use and specify a character encoding such as ISO-8859-1 or UTF-8. When an encoding is not specified, the web browser may choose a different encoding by guessing which encoding is actually being used by the web page. This can cause the web browser to treat certain sequences as special, opening up the client to subtle XSS attacks. See CWE-116 for more mitigations related to encoding/escaping.

To help mitigate XSS attacks against the user's session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user's session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is not supported by all browsers. More importantly, XMLHTTPRequest and other powerful browser technologies provide read access to HTTP headers, including the Set-Cookie header in which the HttpOnly flag is set.

Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a whitelist of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. Do not rely exclusively on looking for malicious or malformed inputs (i.e., do not rely on a blacklist). However, blacklists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.

When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if you are expecting colors such as "red" or "blue."

Ensure that you perform input validation at well-defined interfaces within the application. This will help protect the application even if a component is reused or moved elsewhere.

Reference

CWE Id : 79

WASC Id : 8

Source ID : 1

SQL Injection - SQLite

High (Medium)

Description

SQL injection may be possible.

Instances: 3

Solution

Do not trust client side input, even if there is client side validation in place.

In general, type check all data on the server side.

If the application uses JDBC, use PreparedStatement or CallableStatement, with parameters passed by '?'

If the application uses ASP, use ADO Command Objects with strong type checking and parameterized queries.

If database Stored Procedures can be used, use them.

Do *not* concatenate strings into queries in the stored procedure, or use 'exec', 'exec immediate', or equivalent functionality!

Do not create dynamic SQL queries using simple string concatenation.

Escape all data received from the client.

Apply a 'whitelist' of allowed characters, or a 'blacklist' of disallowed characters in user input.

Apply the principle of least privilege by using the least privileged database user possible.

In particular, avoid using the 'sa' or 'db-owner' database users. This does not eliminate SQL injection, but minimizes its impact.

Grant the minimum database access that is necessary for the application.

Other information

RDBMS [SQLite] likely, given error message regular expression [near ".+": syntax error] matched by the HTML results.

The vulnerability was detected by manipulating the parameter to cause a database error message to be returned and recognised

Reference

CWE Id : 89

WASC Id : 19

Source ID : 1

SQL Injection - Authentication Bypass

High (Medium)

Description

SQL injection may be possible on a login page, potentially allowing the application's authentication mechanism to be bypassed

Instances: 4

Solution

Do not trust client side input, even if there is client side validation in place.

In general, type check all data on the server side.

If the application uses JDBC, use PreparedStatement or CallableStatement, with parameters passed by '?'

If the application uses ASP, use ADO Command Objects with strong type checking and parameterized queries.

If database Stored Procedures can be used, use them.

Do *not* concatenate strings into queries in the stored procedure, or use 'exec', 'exec immediate', or equivalent functionality!

Do not create dynamic SQL queries using simple string concatenation.

Escape all data received from the client.

Apply a 'whitelist' of allowed characters, or a 'blacklist' of disallowed characters in user input.

Apply the principle of least privilege by using the least privileged database user possible.

In particular, avoid using the 'sa' or 'db-owner' database users. This does not eliminate SQL injection, but minimizes its impact.

Grant the minimum database access that is necessary for the application.

Reference

CWE Id : 89

WASC Id : 19

Source ID : 1

Path Traversal

High (Medium)

Description

The Path Traversal attack technique allows an attacker access to files, directories, and commands that potentially reside outside the web document root directory. An attacker may manipulate a URL in such a way that the web site will execute or reveal the contents of arbitrary files anywhere on the web server. Any device that exposes an HTTP-based interface is potentially vulnerable to Path Traversal.

Most web sites restrict user access to a specific portion of the file-system, typically called the "web document root" or "CGI root" directory. These directories contain the files intended for user access and the executable necessary to drive web application functionality. To access files or execute commands anywhere on the file-system, Path Traversal attacks will utilize the ability of special-characters sequences.

The most basic Path Traversal attack uses the "../" special-character sequence to alter the resource location requested in the URL. Although most popular web servers will prevent this technique from escaping the web document root, alternate encodings of the "../" sequence may help bypass the security filters. These method variations include valid and invalid Unicode-encoding ("..%u2216" or "..%c0%af") of the forward slash character, backslash characters ("..\") on Windows-based servers, URL encoded characters "%2e%2e%2f"), and double URL encoding ("..%255c") of the backslash character.

Even if the web server properly restricts Path Traversal attempts in the URL path, a web application itself may still be vulnerable due to improper handling of user-supplied input. This is a common problem of web applications that use template mechanisms or load static text from files. In variations of the attack, the original URL parameter value is substituted with the file name of one of the web application's dynamic scripts. Consequently, the results can reveal source code because the file is interpreted as text instead of an executable script. These techniques often employ additional special characters such as the dot (".") to reveal the listing of the current working directory, or "%00" NULL characters in order to bypass rudimentary file extension checks.

Instances: 1

Solution

Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a whitelist of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. Do not rely exclusively on looking for malicious or malformed inputs (i.e., do not rely on a blacklist). However, blacklists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.

When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if you are expecting colors such as "red" or "blue."

For filenames, use stringent whitelists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses, and exclude directory separators such as "/". Use a whitelist of allowable file extensions.

Warning: if you attempt to cleanse your data, then do so that the end result is not in the form that can be dangerous. A sanitizing mechanism can remove characters such as '.' and ';' which may be required for some exploits. An attacker can try to fool the sanitizing mechanism into "cleaning" data into a dangerous form. Suppose the attacker injects a '.' inside a filename (e.g. "sensi.tiveFile") and the sanitizing mechanism removes the character resulting in the valid filename, "sensitiveFile". If the input data are now assumed to be safe, then the file may be compromised.

Inputs should be decoded and canonicalized to the application's current internal representation before being validated. Make sure that your application does not decode the same input twice. Such errors could be used to bypass whitelist schemes by introducing dangerous inputs after they have been checked.

Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links.

Run your code using the lowest privileges that are required to accomplish the necessary tasks. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.

When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.

Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by your software.

OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows you to specify restrictions on file operations.

This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise.

Reference

CWE Id : 22

WASC Id : 33

Source ID : 1

Cross Site Scripting (Persistent)

High (Medium)

Description

Cross-site Scripting (XSS) is an attack technique that involves echoing attacker-supplied code into a user's browser instance. A browser instance can be a standard web browser client, or a browser object embedded in a software product such as the browser within WinAmp, an RSS reader, or an email client. The code itself is usually written in HTML/JavaScript, but may also extend to VBScript, ActiveX, Java, Flash, or any other browser-supported technology.

When an attacker gets a user's browser to execute his/her code, the code will run within the security context (or zone) of the hosting web site. With this level of privilege, the code has the ability to read, modify and transmit any sensitive data accessible by the browser. A Cross-site Scripted user could have his/her account hijacked (cookie theft), their browser redirected to another location, or possibly shown fraudulent content delivered by the web site they are visiting. Cross-site Scripting attacks essentially compromise the trust relationship between a user and the web site. Applications utilizing browser object instances which load content from the file system may execute code under the local machine zone allowing for system compromise.

There are three types of Cross-site Scripting attacks: non-persistent, persistent and DOM-based.

Non-persistent attacks and DOM-based attacks require a user to either visit a specially crafted link laced with malicious code, or visit a malicious web page containing a web form, which when posted to the vulnerable site, will mount the attack. Using a malicious form will oftentimes take place when the vulnerable resource only accepts HTTP POST requests. In such a case, the form can be submitted automatically, without the victim's knowledge (e.g. by using JavaScript). Upon clicking on the malicious link or submitting the malicious form, the XSS payload will get echoed back and will get interpreted by the user's browser and execute. Another technique to send almost arbitrary requests (GET and POST) is by using an embedded client, such as Adobe Flash.

Persistent attacks occur when the malicious code is submitted to a web site where it's stored for a period of time. Examples of an attacker's favorite targets often include message board posts, web mail messages, and web chat software. The unsuspecting user is not required to interact with any additional site/link (e.g. an attacker site or a malicious link sent via email), just simply view the web page containing the code.

Instances: 3

Solution

Phase: Architecture and Design

Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

Examples of libraries and frameworks that make it easier to generate properly encoded output include Microsoft's Anti-XSS library, the OWASP ESAPI Encoding module, and Apache Wicket.

Phases: Implementation; Architecture and Design

Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required encoding strategies.

For any data that will be output to another web page, especially any data that was received from external inputs, use the appropriate encoding on all non-alphanumeric characters.

Consult the XSS Prevention Cheat Sheet for more details on the types of encoding and escaping that are needed.

Phase: Architecture and Design

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.

Phase: Implementation

For every web page that is generated, use and specify a character encoding such as ISO-8859-1 or UTF-8. When an encoding is not specified, the web browser may choose a different encoding by guessing which encoding is actually being used by the web page. This can cause the web browser to treat certain sequences as special, opening up the client to subtle XSS attacks. See CWE-116 for more mitigations related to encoding/escaping.

To help mitigate XSS attacks against the user's session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user's session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is not supported by all browsers. More importantly, XMLHTTPRequest and other powerful browser technologies provide read access to HTTP headers, including the Set-Cookie header in which the HttpOnly flag is set.

Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a whitelist of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. Do not rely exclusively on looking for malicious or malformed inputs (i.e., do not rely on a blacklist). However, blacklists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.

When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if you are expecting colors such as "red" or "blue."

Ensure that you perform input validation at well-defined interfaces within the application. This will help protect the application even if a component is reused or moved elsewhere.

Other information

Source URL: http://127.0.0.1:8528/cgi-bin/badstore.cgi?action=doguestbook

Reference

CWE Id : 79

WASC Id : 8

Source ID : 1

SQL Injection

High (Medium)

Description

SQL injection may be possible.

Instances: 1

Solution

Do not trust client side input, even if there is client side validation in place.

In general, type check all data on the server side.

If the application uses JDBC, use PreparedStatement or CallableStatement, with parameters passed by '?'

If the application uses ASP, use ADO Command Objects with strong type checking and parameterized queries.

If database Stored Procedures can be used, use them.

Do *not* concatenate strings into queries in the stored procedure, or use 'exec', 'exec immediate', or equivalent functionality!

Do not create dynamic SQL queries using simple string concatenation.

Escape all data received from the client.

Apply a 'whitelist' of allowed characters, or a 'blacklist' of disallowed characters in user input.

Apply the principle of least privilege by using the least privileged database user possible.

In particular, avoid using the 'sa' or 'db-owner' database users. This does not eliminate SQL injection, but minimizes its impact.

Grant the minimum database access that is necessary for the application.

Other information

The page results were successfully manipulated using the boolean conditions [ZAP' AND '1'='1' -- ] and [ZAP' AND '1'='2' -- ]

The parameter value being modified was NOT stripped from the HTML output for the purposes of the comparison

Data was returned for the original parameter.

The vulnerability was detected by successfully restricting the data originally returned, by manipulating the parameter

Reference

CWE Id : 89

WASC Id : 19

Source ID : 1

X-Frame-Options Header Not Set

Medium (Medium)

Description

X-Frame-Options header is not included in the HTTP response to protect against 'ClickJacking' attacks.

Instances: 39

Solution

Most modern Web browsers support the X-Frame-Options HTTP header. Ensure it's set on all web pages returned by your site (if you expect the page to be framed only by pages on your server (e.g. it's part of a FRAMESET) then you'll want to use SAMEORIGIN, otherwise if you never expect the page to be framed, you should use DENY. ALLOW-FROM allows specific websites to frame the web page in supported web browsers).

Reference

CWE Id : 16

WASC Id : 15

Source ID : 3

Application Error Disclosure

Medium (Medium)

Description

This page contains an error/warning message that may disclose sensitive information like the location of the file that produced the unhandled exception. This information can be used to launch further attacks against the web application. The alert could be a false positive if the error message is found inside a documentation page.

Instances: 1

Solution

Review the source code of this page. Implement custom error pages. Consider implementing a mechanism to provide a unique error reference/identifier to the client (browser) while logging the details on the server side and not exposing them to the user.

Reference

CWE Id : 200

WASC Id : 13

Source ID : 3

X-Frame-Options Header Not Set

Medium (Medium)

Description

X-Frame-Options header is not included in the HTTP response to protect against 'ClickJacking' attacks.

Instances: 1

Solution

Most modern Web browsers support the X-Frame-Options HTTP header. Ensure it's set on all web pages returned by your site (if you expect the page to be framed only by pages on your server (e.g. it's part of a FRAMESET) then you'll want to use SAMEORIGIN, otherwise if you never expect the page to be framed, you should use DENY. ALLOW-FROM allows specific websites to frame the web page in supported web browsers).

Reference

CWE Id : 16

WASC Id : 15

Source ID : 3

X-Content-Type-Options Header Missing

Low (Medium)

Description

The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.

Instances: 61

Solution

Ensure that the application/web server sets the Content-Type header appropriately, and that it sets the X-Content-Type-Options header to 'nosniff' for all web pages.

If possible, ensure that the end user uses a standards-compliant and modern web browser that does not perform MIME-sniffing at all, or that can be directed by the web application/web server to not perform MIME-sniffing.

Other information

This issue still applies to error type pages (401, 403, 500, etc) as those pages are often still affected by injection issues, in which case there is still concern for browsers sniffing pages away from their actual content type.

At "High" threshold this scanner will not alert on client or server error responses.

Reference

CWE Id : 16

WASC Id : 15

Source ID : 3

Cookie No HttpOnly Flag

Low (Medium)

Description

A cookie has been set without the HttpOnly flag, which means that the cookie can be accessed by JavaScript. If a malicious script can be run on this page then the cookie will be accessible and can be transmitted to another site. If this is a session cookie then session hijacking may be possible.

Instances: 2

Solution

Ensure that the HttpOnly flag is set for all cookies.

Reference

CWE Id : 16

WASC Id : 13

Source ID : 3

Web Browser XSS Protection Not Enabled

Low (Medium)

Description

Web Browser XSS Protection is not enabled, or is disabled by the configuration of the 'X-XSS-Protection' HTTP response header on the web server

Instances: 39

Solution

Ensure that the web browser's XSS filter is enabled, by setting the X-XSS-Protection HTTP response header to '1'.

Other information

The X-XSS-Protection HTTP response header allows the web server to enable or disable the web browser's XSS protection mechanism. The following values would attempt to enable it:

X-XSS-Protection: 1; mode=block

X-XSS-Protection: 1; report=http://www.example.com/xss

The following values would disable it:

X-XSS-Protection: 0

The X-XSS-Protection HTTP response header is currently supported on Internet Explorer, Chrome and Safari (WebKit).

Note that this alert is only raised if the response body could potentially contain an XSS payload (with a text-based content type, with a non-zero length).

Reference

CWE Id : 933

WASC Id : 14

Source ID : 3

Content-Type Header Missing

Low (Medium)

Description

The Content-Type header was either missing or empty.

Instances: 5

Solution

Ensure each page is setting the specific and appropriate content-type value for the content being delivered.

Reference

CWE Id : 345

WASC Id : 12

Source ID : 3

X-Content-Type-Options Header Missing

Low (Medium)

Description

The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.

Instances: 2

Solution

Ensure that the application/web server sets the Content-Type header appropriately, and that it sets the X-Content-Type-Options header to 'nosniff' for all web pages.

If possible, ensure that the end user uses a standards-compliant and modern web browser that does not perform MIME-sniffing at all, or that can be directed by the web application/web server to not perform MIME-sniffing.

Other information

This issue still applies to error type pages (401, 403, 500, etc) as those pages are often still affected by injection issues, in which case there is still concern for browsers sniffing pages away from their actual content type.

At "High" threshold this scanner will not alert on client or server error responses.

Reference

CWE Id : 16

WASC Id : 15

Source ID : 3

Web Browser XSS Protection Not Enabled

Low (Medium)

Description

Web Browser XSS Protection is not enabled, or is disabled by the configuration of the 'X-XSS-Protection' HTTP response header on the web server

Instances: 1

Solution

Ensure that the web browser's XSS filter is enabled, by setting the X-XSS-Protection HTTP response header to '1'.

Other information

The X-XSS-Protection HTTP response header allows the web server to enable or disable the web browser's XSS protection mechanism. The following values would attempt to enable it:

X-XSS-Protection: 1; mode=block

X-XSS-Protection: 1; report=http://www.example.com/xss

The following values would disable it:

X-XSS-Protection: 0

The X-XSS-Protection HTTP response header is currently supported on Internet Explorer, Chrome and Safari (WebKit).

Note that this alert is only raised if the response body could potentially contain an XSS payload (with a text-based content type, with a non-zero length).

Reference

CWE Id : 933

WASC Id : 14

Source ID : 3

30代になる前に描いてみたモチベーショングラフ-ダメダメエンジニアの成鳥日記-

どーも。ばぁどです。 なんか成鳥成長っていう単語、やけに学生時代に使っていたなと思っていて、なんか当時の他団体の方に「成長の先に何があるの?」ということを聞かれて何も回答できなかった筆者でございます。

今回は前回の学生編に続き社会人編の振り返りです。

学生編(①~⑦)はこちら

ultrabirdtech.hatenablog.com

f:id:UltraBirdTech:20211026180713p:plain

8. 新人研修でJavaを学ぶの巻

筆者が最初に入社した企業は独立系・受託開発会社でした。規模は中小企業です。 内定をもらった学生時代の7月、8月頃から内定者研修として週に一度本社に通いJavaSQLを学んだ記憶があります。 当時はJavaの資格やSQLの資格も取得が義務付けられており、非常に忙しい日々を過ごしていた思い出があります。

入社した4月から本格的に業務で必要なJavaを学んでいきましたが、富士山の麓で行われている地獄の合宿に参加したり、サークル活動で培ったリーダーシップを発揮しつつも技術力が全く追いつかない辛い日々が続いたなと記憶しています。 初期の頃はエンジニアの本質の力である技術力が足りていないにもかかわらず、リーダーシップとかExcelの資料を作るのが上手いとか小手先の力で「なんかできている風」が出ちゃうのは個人的に今でも抱えている反省点の一つです。本来は本質的な力である技術力を伸ばさなければいけない時期に、小手先の力でできている風になっちゃうのはエンジニアとして本当に求めていない結果であります。

業務で必要な技術力が追いつかないこともあり、非常にモチベーションが下がる日々が続いていました。

9. エンジニア人生の転換期

エンジニア1年目で転機が訪れます。 当時、部門長であった上司の直属の案件にアサインされることになりました。 この案件でエンジニアとして必要な技術力をどのように学ぶかなどの基礎を叩き込まれました。 筆者が初期の頃愛用していたRubyに出会ったのもこの時期です。(最近はもっぱらPythonですが・・・)

部門長であった上司の多大な影響を受けた結果、筆者は朝7:30には会社のオフィスに出社し始業開始の8:30まで自主勉強をする日々を送ることになりました。昼休みもお昼ご飯を食べずにひたすら勉強という非常にストイックな日々を送っておりました。 まぁ、これもそれもそもそも技術力が備わっていない筆者の未熟な部分をカバーしようともがきにもがいた一つの結果だったのかなと振り返っております。 ちなみに筆者は朝方の人間だったので、毎朝5:30などに起きていたので7:30に会社にいるのは造作もないことでした。

また朝の時間だけではありません。 残業も禁止された上で、定時に仕事を切り上げて業務後の時間も勉強に充てることになりました。 なので、朝の7:30-8:30の1時間、昼休みの1時間、業務を切り上げて帰宅した後の7:30から就寝までの時間全てを勉強の時間に当てることができました。また、土日の時間も同様です。一刻も早く一人前のエンジニアになるためにただただがむしゃらに勉強を続けた日々が続いたと記憶しています。

今の技術力があるのは、1年目、2年目の頃のこのがむしゃらな努力が実った結果だったのかなと思います。

10. 派遣先でクビを切られたお話と自信を取り戻すまでのお話

そんな技術力が発展途上であったとある日事件が起きます。 詳細は書きませんが、2年目の冬に派遣先であった案件で紆余曲折あり、案件のクビを宣告されました。

今振り返ると確かに自身は技術力が不足していたり、プロジェクト全体に大きな影響を与えてしまったりなど大変申し訳ない気持ちでいっぱいです。この出来事は、当時の筆者のメンタルに非常に影響を与えており、エンジニアとして自信喪失し、何をやっても上手くいかない日々が続きます。

今の筆者なら、有給とってリフレッシュとか、休職とかも選択肢に入れて考えたりするのですが、当時はそんな考えも思い浮かばず、ダメなメンタルをずっと引きずってばかりでした。

しかし、この後アサインされた案件が非常に良い案件であり、そこでエンジニアとしての成果を確実に出すことができ徐々にエンジニアとしての自信を取り戻していくことになります。フレンドリーな会社の先輩と2人で約2年近く一緒に働いたのを覚えています。筆者のエンジニア人生の中で2回目の非常に貴重な時期でした。身近な年齢で常に目標となる方がそばにいてくれることは非常に貴重です。

また、この時期が一般的に言われるプロフェッショナルになるための10,000時間を超えたあたりだったのか分かりませんが、社会人3年目の後半からエンジニアとしての仕事も急に楽になったなと感じております。

ちなみにこのブロックは転職面接時の「挫折した経験とそれをどう乗り越えたか」を話す時の鉄板ネタです。

11. 情報処理安全確保支援士の合格

1年目、2年目の頃から続けた勉強が功をなしたのか、社会人4年目という比較的早い段階で高度技術者試験の一つであった情報処理安全確保支援士の試験に合格します。 当時初めてできたIT系の仕業(弁護士とか税理士みたいに名乗れる)だったので、すごい嬉しかった思い出があります。

こういうのにすぐに感化されちゃうのが、筆者の悪い癖です。 情報処理安全確保支援士として登録して、すぐに名乗りたくなっちゃう。 ただ、この仕業というのが非常に厄介で情報処理安全確保支援士になっておきながらサイバーセキュリティの仕事に従事していなかったんですよね。だからこそ、情報処理安全確保支援士としての試験は突破して名乗れるようになったものの、情報処理安全確保支援士として何か仕事ができるかというと大きな”はてな”が浮かびます。

12. 転職って難しい

Webアプリケーションを開発できる人材は世の中に沢山います。 社会人5年目になると、社外の人との差別化も必死にはかりたくなるお年頃でございます。

そんな中、学生時代から知り合いである方が経営している会社から転職のお誘いを受けて転職。 半年で辞める形となってしまいましたが、1社目から旅立つきっかけを頂けたのは非常にありがたいことでした。

この頃に前項で書いたサイバーセキュリティの道へと進む決心がつき、本格的に行動にうつすことになります。

13. 昔取った杵柄ってあるんだなぁ

2度目の転職をしてSESでしたが、現場が非常に面白い現場でした。 サイバーセキュリティの講師をやる必要があり、筆者学生時代に学んだ教職(人に何かを教える技術)が役立ちました。 人に何かを教えるということは、自分自身の理解も重要であるので自身も勉強をしながら、何かを教えていくというのは非常に大変でしたが、なんとか乗り切ることができました。

14. メンタル崩壊&コロナ禍へ突入

プライベートで少しメンタルが崩壊するような出来事があり、コロナ禍にも突入し、あまりメンタルが安定しない時期が続きました。 誰かに相談しようとも「人に会うこと自体が否」とされており、非常に辛い日々を過ごしました。

仕事面はギリギリ順調でしたので、なんとか立て直すことはできました。 年末の評価でも”社長賞”といった表彰もしていただきました。 会社や部門からの表彰は、1社目の頃から毎年何かしらの形で表彰していただいているので、そういった前向きな行動は引き続き継続していきたいと考えております。

15. 3度目の転職をして今

より本格的にサイバーセキュリティを仕事にするために3度目の転職になります。 仕事もWebアプリケーション開発者から脆弱性診断士/セキュリティコンサルタントと様変わりしております。

ベースとなるITの知識は一緒ですが、Webアプリケーションを作る側と、守る側という全く別の視野が必要なことから、色々と苦労している最中でございます。ただ、あまり本格的に両者の経験を持ち、開発と守る側の視野を持ち合わせたエンジニアはいないはずなので、そういった市場で活躍していけるようにひたすら努力です。

しかし自身が選んだ道とはいえ、30代の今になって技術の学び直しはお勧めしないです・・・マジ辛い苦笑

本当は同時期に大企業様のWebアプリケーション開発枠の内定もいただいていたのですが、結局は選んだのは自分の責任。 まぁJavaっていうのがあまり魅力的じゃなかったし、業務内容もちと辛かったからなぁ・・・これがRubyとかPythonで別業務だったら、間違いなく選んでいましたね。

まとめ

もう少しゆっくり振り返ろうと思いましたが、勢いで振り返ってしまいました。

あまり過去に縋り付くことなく、今の現実を受け入れて、30代をどう過ごすか、どう行動していくかを考えていこうと思います。

30代になる前に描いてみたモチベーショングラフ-社会人の基礎になった学生時代-

どーも。ばぁどです。

もうすぐ30代に突入ということで、30代をどういった風に過ごそうかということをぼんやり考えております。 未来を考えるためには、過去を分析して現在に繋げる必要があると考えたため、モチベーショングラフを描いてみて自己分析してみました。

f:id:UltraBirdTech:20211026180713p:plain

①暗黒の高校時代(2010年3月)

筆者のスタートは高校時代のマイナススタートです。 あまり良い高校時代ではなかったなと振り返ります。 自己表現が下手で、体育会系の高校だったのですが本人はもろ文化系。クラスメイトの大半が野球部やサッカー部、バスケ部、バレーボール部の中、パソコン部という異端児。割と部活で固まるような性質があったし、自己表現も苦手だったので、とてもではないが良い高校時代ではなかったなと振り返ります。

②大学入学、環境サークルへ参加(2010年4月-6月)

大学は高校時代とうってかわって文化系の人が多い大学でした。文化系というかオタクというか・・・。まぁ筆者の肌にはあっていたと思います。 環境を変えるというのは人が変わるためのとても良いタイミングではあるので、拙い頭であった高校時代の筆者が大学に進学するという選択をしたのは、とても良い選択だったと振り返ります。 高校時代の成功体験が何もない状態で社会に出ていたら、おそらくメンタル病んでいたに違いない・・・

また、大学入学時に当時大学内の環境美化を担当していた環境サークルに参加します。 サークルと表現すると少し違和感があるのですが、まぁ良いとしましょう。 そのサークルは大学のイベントである夏祭りや学祭などには団体として参加していましたし、一緒に何かを達成する仲間がいるというのはとても良い経験でした。 高校時代の部活とは違い地区大会を勝ち上がるなどの明確な目標が与えられず、顧問の先生といった管理してくれるような大人がいない中、自分たちで漠然とした目標に対してどのようなプローチで行動していくかを考えることができた経験はとても良い経験でした。

③サークル副代表、初ギャザ、初めての後輩(2010年10月-2011年4月)

大学1年次の秋から冬にかけては、更なる転機が訪れます。 まずは環境サークル内で副代表に選出されたこと。 大学のサークルは1年毎に代替わりが行われており、そのタイミングで副代表に選出していただけました。 当時周りの同期からの推薦で副代表に選ばれた記憶なのですが、なんで選んでくれたのかとかもっと聞いておけばよかった・・・ とはいえ、自身としては特に環境系の問題に対して知識があるわけでもなく、副代表としての器があるかも疑わしかったので、とにかくがむしゃらに与えられた職務を全うするしかなかったです。 この副代表に選ばれると言う経験は暗黒時代であった高校時代から考えると決して想像できない大快挙ではありました。

その後3月にギャザリングという当時某界隈では有名なイベントに参加しました。 日本中で環境活動をしている大学生が、合宿所に集まり三日三晩ワークをやったり、ディスカッションしたりするといったイベントです。 まぁ自分自身が参加しているサークルとの違いや、外部の環境サークルの活動を聞くことができ視野が広がったのは間違いありません。 このイベントで出会った友人とは今でも連絡を取り合い、転職先を相談したり、気分が落ち込んだ時は駆けつけてくれたり、とても良い出会いに恵まれたと思います。

この合宿イベントの後数日後に起こったのが3.11でした。 筆者は環境サークルの活動であるリサイクルショップの荷物の搬入作業待機中の被災でした。

4月には、初めての後輩が入ってきてなんか色々とわちゃわちゃした覚えがあります(適当。 ただ振り返るといまだに先輩として不適格だったなという部分も多々あり、非常に申し訳ない気持ちに駆られる時期でもあります。

④代表落選・地方イベント参加・ITの勉強を本格的に始める(2011年11月-2012年3月)

そんなこんなで1年経ち、サークル活動も再び代替わりの時期になり代表戦となります。 結果から言うと、代表選に立候補するも実力が足りずに落選。 当時は非常に悔しかったですが振り返ると結果は当たり前だったかなと思います。明らかに考えが足りておらず、組織をどうしていきたいかとか全く考えていなかったので。

まぁ悔しいものは悔しかったので、考え抜いた結果「今のままの自分じゃダメだ」と痛感し色々と新しいことを始めます。拙い頭しか持っていない当時の筆者のわりには、良い線の答えを一人で導き出したなと思います。 この時に出した答えが地方で開催されていた環境イベント(みちのくG)の単身参加と専攻していた情報技術の勉強の本格化です。 前者は東北で開催されていた環境イベントに単身突入しました。完全アウェイな状況に一人で乗り込む経験は非常に貴重な経験でした。なんかこの時期から移動するためのフットワークが一気に軽くなった印象です。 また、情報技術の勉強としてITパスポートや基本情報技術者の勉強を始めたのもこの時期です。基本情報技術者試験を取得できたのは社会人になってからですが、この時の勉強した努力は間違いなかったなと思います。

⑤人生を変える講義、サークル活動最盛期、初海外(2012年4月-2012年9月)

大学3年次には人生を変える講義というか、キャリアデザインという大学の講義があり、そちらの講師に非常にお世話になりました。就職活動という大学生活最大のイベントを控えており、キャリアデザインという講義の中で自身のキャリアについて色々と考えさせられました。 社会人としての基礎や、サークル活動で培ってきた経験の言語化などはこの時期に行っており、筆者のWBS作成などのプロジェクトマネジメント力が育まれた最初期はこの時期です。

サークル活動もこの時期が最盛期を迎えており、大学の環境サークル活動の他に外部の環境サークルとインカレ団体立ち上げて日本中で同時多発的なゴミ拾いを行う団体だったり、国際的なサークルに所属したりしていました。 また時期的には少し後になるのですが、自信が趣味である特撮に関するサークルを自身で立ち上げたのもこの時期です。 自分でサークルを立ち上げるという経験はなかなかできないものであり、環境サークルでの経験を最大限に生かすことができたなと感じております。

またインド研修という初海外もこの時期です。 初めての海外がインドだということは今でも非常に驚かれます。カレーが美味しかったです。

⑥就職活動、教育実習(2012年12月-2013年6月)

大学生の一大イベントである就職活動です。 筆者が学生時代の頃は、大学3年次の12月解禁でした。 やはり普段は接していない社会人の方々と触れ合う機会は、自身の足りていない考えが露わになっていくこともあり非常に辛い時期でした。 運よく大学3年次の春休みだけで就職活動を終えることがでたのは非常に幸運でした。

その後一時的に燃え尽き症候群のようなものがあり、大学のゼミも本格的に始まり、教育実習がボロボロでありなんだかんだモチベーションが落ちる日々が続きました。

⑦大学生活ラストスパート(2013年7月-2014年3月)

学生生活ラストスパートは、就職先がIT系だったので学生のうちに飲食系のアルバイトを経験しておこうと某ハンバーガーチェーン店のバイトを始めてみたり、自身の趣味であった特撮サークルで特撮が好きな仲間たちとわちゃわちゃしたりしていました。

特に飲食系のアルバイトでは毎朝7:00-10:00の超朝方のシフトで入っており、自身の特性に非常にマッチした日常を過ごすことができました。この経験は社会人初期の勉強スタイルにもなっていたので、非常に良い気づきでした。

特撮サークルも筆者が大学を卒業してもう8年ほど経ちますが、未だに後輩たちがサークルを継続してくれており来年にはサークル設立10年目を迎えるそうです。とても嬉しいです。

まとめ

社会人になる時の基礎が学生時代に築かれたなと改めて感じました。 後悔はありませんが反省するべきところは多々ある学生時代だったと思います。

モチベーショングラフは学生時代の振り返りということで一旦ここまで。そのうち社会人パートも書こうと思います。

社会人パートは下記です。

ultrabirdtech.hatenablog.com

【注意喚起】amazonのフィッシングメールが届いたお話【注意喚起】

2021年10月3日 20:56 頃 amazon prime を語るフィッシングメールが届きました。

サイバーセキュリティを生業にしている筆者に対して送るとは何事!!少し調べてみました。

f:id:UltraBirdTech:20211003214158j:plain

amazon さんの対応も非常に早いです。

日曜日にも関わらずお仕事、お疲れ様ですmm

amazon help 様に案内されたURLは下記です。こちらでも貼っておきます。

https://www.amazon.co.jp/gp/help/customer/display.html?nodeId=201304810&linkId=47088724&linkId=47752923&linkId=49786956

そもそもフィッシングサイトとは?

フィッシングサイトとは、個人情報やログイン情報、会社の機密情報を奪うために仕組まれた罠サイトです。

今回のようにドメインを本物のように見せかけて、さも誰もがクリックしたいような文言を追加して送り込んできます。

このような攻撃の被害を受けることで、個人情報、ログイン情報、機密情報の漏洩につながります。

下記は総務省のフィッシングサイトに対するWebページです。

www.soumu.go.jp

もしフィッシングサイトに引っかかってしまったら?

兎にも角にも、奪われしまったものは取り返しようがありません。

ログイン情報の場合は、すぐに対象システムのパスワードの変更を強く推奨します。

またもしパスワードを使い回している方がいたら、同じパスワードを用いているシステムのパスワードも同様に別のものに変更することを強く推奨します。

警視庁もフィッシング110番ということで、サイトを立ち上げてくれています。

www.keishicho.metro.tokyo.lg.jp

念の為筆者からも警視庁への情報提供をしておきました。

対象URLのサイト

※対象のURLは絶対に開かないでください。

警告になりますが、対象のURLは絶対に開かないでください。 サイトによっては、サイトにアクセスするだけで悪いプログラムをダウンロードしてくるようなものもあります。 筆者は情報処理安全確保支援士なのでご勘弁を。

安全を考慮してアクセスしてみたところ下記サイトが表示されました。 ※URLは安全のためマスクしています。

f:id:UltraBirdTech:20211003212437p:plain

あー、これは紛れもないフィッシングサイトですね。 amzonを語っていますが、所々がフィッシングサイトであるという証拠しか並んでおりません。

怪しいと思うポイントをいくつかみていきましょう。

ドメインがおかしい

今回、送られてきたフィッシングサイトのアドレスは awsという文字列は入っていますが明らかな偽物でした。 amazonさんが使用しているドメインは下記に記載がありますので、参考としていただければと思います。

基本的にamazon が運営しているドメインhttps://××.amazon.co.jp/またはamazon.co.jp/で始まるとのことです。

f:id:UltraBirdTech:20211003212954p:plain

https://www.amazon.co.jp/gp/help/customer/display.html?nodeId=201304810&linkId=47088724&linkId=47752923&linkId=49786956

amazonと語っていながらも、上記ドメインでは無い場合は注意しましょう。

httpsになっていない

GAFAの一つに数えられる Amazon さんのログインページがHTTPSになっていない!そんなことはありえない!

f:id:UltraBirdTech:20211003212627p:plain

httpsは通信の暗号化のことです(ざっくり 近年ではログインページなど重要な情報を送る場合はhttpsはほぼ必須として扱われています。

使用されている技術

Google Chrome の Wappalyzer という拡張機能を用いて確認しています。

本物のログインページ

f:id:UltraBirdTech:20211003213625p:plain

本家本物はJavaScriptをフロントエンドで用いており、バックエンドは基本的に aws を用いておりますね。流石の一言。

www.amazon.co.jp

偽物のログインページ

本家本物に対して、偽物のログインページは下記の技術を使用。

f:id:UltraBirdTech:20211003214520p:plain

amazon系の技術は使用していないようですね。 WebサーバーとしてApache、言語としてPHPを用いています。

ちなみに。

フィッシングサイトのログインページに設定されている各種リンクは本物のサイトのものが使われていました。

whois

試しに'whois'でドメイン情報を探索してみました。 住所を調べてみたら都内某所のコワーキングスペースが出てきました。

※所々★でマスキングしています。

whois www.aws-y.★★★
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object

refer:        whois.nic.shop

domain:       SHOP

organisation: GMO Registry, Inc.
address:      26-1 ★★★★★★ Shibuya-ku, Tokyo
address:      Japan

contact:      administrative
name:         Representative Director and CEO
organisation: GMO Registry, Inc.
address:      ★★★★★ Tower, ★★-1 ★★★★★★★, ★★★★★★-★★, Tokyo
address:      Japan
phone:        +81★★★★★★★★★
fax-no:       +81★★★★★★★★★
e-mail:       newgtld@★★★★★.com

contact:      technical
name:         Director
organisation: GMO Registry, Inc.
address:      ★★★★★ Tower, ★★-1 ★★★★★★★, ★★★★★★-★★, Tokyo
address:      Japan
phone:        +81★★★★★★★★★
fax-no:       +81★★★★★★★★★
e-mail:       ★★★★★@★★★★★.com

nserver:      A.GMOREGISTRY.NET 2001:dcd:1:0:0:0:0:4 37.209.192.4
nserver:      B.GMOREGISTRY.NET 2001:dcd:2:0:0:0:0:4 37.209.194.4
nserver:      K.GMOREGISTRY.NET 37.209.196.4
nserver:      L.GMOREGISTRY.NET 2001:dcd:4:0:0:0:0:4 37.209.198.4
ds-rdata:     50701 8 2 30f44f9e79f1119aebed349d3ec34f7aedd83a58f1e706d8303c3bbfe83bc7ec

whois:        whois.nic.shop

status:       ACTIVE
remarks:      Registration information: http://www.gmoregistry.com/en/

created:      2016-05-05
changed:      2019-07-13
source:       IANA

# whois.nic.shop

The queried object does not exist: NAMESERVER NOT FOUND
URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of WHOIS database: 2021-10-03T11:56:52.0Z <<<

サイトをリロードすると・・・

フィッシングサイトをリロードすると404に。Apacheのデフォルトページの404ページが見れますね。

f:id:UltraBirdTech:20211003215216p:plain

ファビコンはamzonのもののままですね。

リクエストとレスポンスを確認してみた

BurpSuiteを用いてリクエストとレスポンスを確認してみました。

HTTP/1.1 200 OK
Date: Sun, 03 Oct 2021 13:15:36 GMT
Server: Apache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Allow-Credentials: true
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Upgrade: h2
Connection: Upgrade, close
Vary: Accept-Encoding
Content-Length: 77
Content-Type: text/html;charset=utf-8

{"countryname":"Japan","region":"★★★","ip":"★★★.★★★.★★.★★★","mode":"pc"}

あー、攻撃者にIPアドレスがバレてしまっていますね。怖い怖い。 念の為筆者は、違う場所を経由してアクセスしているので問題なしと。

このように攻撃者に接続元のIPアドレスが知られてしまうので要注意です。

最後に

フィッシングの被害に遭わないように気をつけてください。

あと初めて情報処理安全確保支援士っぽいことをした気がする。

BurpSuiteの拡張機能をPythonで作ってみたお話

どーも、ばぁどです。 BurpSuiteの拡張機能Pythonで書いてみました。

なぜやろうと思ったのか

BurpSuiteと仲良くなりたかったのことをよく知りたかったからです。

脆弱性診断にジョブチェンしてBurpSuiteというローカルプロキシツールに出会いました。 今までWebアプリケーション開発を生業にしていた筆者からしたら、あまり絡むことのなかったツールであり、要領を掴むのが大変でした。 とある日、会社のメンバーがPythonでButpSuiteの拡張機能を書いていることを知り、プログラマとしての経験を活かしながらBurpSuiteを知ることができると思い、拡張機能を書いてみた次第です。

実行結果

下図のように、BurpSuiteを中継してサーバーに飛ぶリクエストにオリジナルのヘッダーをつけることができます。

f:id:UltraBirdTech:20211002201702p:plain
OriginalHeader

下記のオリジナルのヘッダーが付与されていることがわかりますか?(赤枠部分)

X-Original-Header: UltraBird

リクエストにオリジナルヘッダーが付くイメージは下記のようなイメージです。 今回のオリジナルヘッダーを確認するためには、BurpSuiteを二つ立ち上げる必要があります。

f:id:UltraBirdTech:20211002203201p:plain

このサンプルを拡張機能として作ったからといって、何ができるかというと、別に何も影響はないのですが苦笑。今回のサンプルを用いながら、今後診断業務が便利になるコードを書いていきたい。

書いたコード

from burp import IBurpExtender
from burp import IHttpListener

class BurpExtender(IBurpExtender, IHttpListener):
    def __init__(self):
        self.new_header = "X-Original-Header: UltraBird"

    def registerExtenderCallbacks(self, callbacks):
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()
        callbacks.setExtensionName("My Original Extension")
        callbacks.registerHttpListener(self)
        return

    def processHttpMessage(self, tool_flag, is_message_request, current_request):
        if not is_message_request:
            return

        request_info = self.get_request_info(current_request)

        header_list = self.get_header_from_current_request(request_info)
        body_info = self.get_body_from_current_request(current_request, request_info)

        new_request = self.create_new_request(header_list, body_info)
        current_request.setRequest(new_request)

        return

    def get_request_info(self, current_request):
        return self._helpers.analyzeRequest(current_request)

    def get_header_from_current_request(self, request_info):
        return list(request_info.getHeaders())

    def get_body_from_current_request(self, current_request, request_info):
        body_bytes = current_request.getRequest()[request_info.getBodyOffset():]
        return self._helpers.bytesToString(body_bytes)

    def create_new_request(self, header_list, body_info):
        header_list.append(self.new_header)
        return self._helpers.buildHttpMessage(header_list, body_info)

コードはBurpSuiteの公式リファレンスを参考にしつつ、インターネット上のものを参考にしながら作成させていただきました。 ユニットテストもそのうち追加したい。

portswigger.net

備忘録:BurpSuiteでPythonの拡張コードを読み込ませる方法

BurpSuiteは基本的にJavaで動いています。 BurpSuiteを動かすときにjarを利用することがあれば、拡張機能も大部分がjarで配布されており、jarファイルを読み込むことで拡張機能を使用することができます。

今回はPython拡張機能を書いたため、BurpSuiteでPythonを読み込めるようにする必要があります。

手順1. Jython ファイルを入手する

最初にJavaで動いているBurpSuiteにPythonを読み込ませるためのjarファイルをjythonの公式サイトから用意します。

www.jython.org

[Extender]→[Options]→[Python Environment]→[select File...]から、ダウンロードしたjarファイルを読み込ませます。

f:id:UltraBirdTech:20211002204030p:plain

対象ファイルを選択して[Open]をクリックするとjarファイルが読み込まれます。 f:id:UltraBirdTech:20211002204322p:plain

手順2. Pyhonを読み込む拡張機能を追加する

Python Scripter という拡張機能を読み込ませます。

github.com

[Extender]→[B App Store] →(検索ボックスで)[python scripter]と検索し、インストール。

f:id:UltraBirdTech:20211002204557p:plain

手順3. 作成したPythonコードを拡張機能として読み込ませる

[Extender]→[Extentions]→[Add] f:id:UltraBirdTech:20211002205007p:plain

[Java]を[Python]に変更し、[Select file...]をクリック。

f:id:UltraBirdTech:20211002205231p:plain

作成したPython ファイルを選択する。

f:id:UltraBirdTech:20211002205724p:plain

手順4. 読み込まれたことを確認して終了

もしPythonコードにエラーがあれば、この時点でエラーだとわかります。

f:id:UltraBirdTech:20211002205913p:plain

エラーが出なければ完了です。お疲れ様でした。

まとめ

まだBurpSuiteを触りきれていないので、どういったツール、拡張機能があれば便利なのかはわかっていないです。しかし今後脆弱性診断を続けて行くにつれて、そういった視野が開けて行くことに期待しております。

【番外編】ハニーポット観察日誌・兵庫で出会ったハニーポット

どーも、ばぁどです。久々にハニーポットの話題を。 一時期筆者がハニーポットにハマっており、ハニーポッターとして観察ブログや勉強会にも参加していた頃がおそらく3、4年前だったかと記憶しております。

ultrabirdtech.hatenablog.com

当時はハニーポット勉強会が定期的にオフラインで行われていました(まだコロナ禍ではない頃のお話です)。 なんだったらエンジニア界隈を騒つかせた、無限アラート事件の前だったかな。 ハニーポット勉強会で共有していただいたのが、今回ご紹介するハニーポットです。やっと"食べることができる"ハニーポットに巡り会うことができました。

ハニーポットとは?

ハニーポット (英語: Honeypot) は、コンピュータセキュリティにおいて、悪意のある攻撃を受けやすいように設定した機器を、おとりとしてネットワーク上に公開することにより、サイバー攻撃を誘引し、攻撃者の特定や攻撃手法を分析する手法、あるいは、そのような用途で使用するシステムをいう。 ハニーポットを設置する目的は、ウイルスやワームの検体の入手、不正アクセスを行うクラッカーをおびき寄せ重要なシステムから攻撃をそらしたり、記録された操作ログ・通信ログなどから不正アクセスの手法と傾向の調査を行うなどである。

Wikipediaより引用 ja.wikipedia.org

ではなくて、今回の記事はこちらの紹介。

ma-couleur.jp

神戸に本店を構えるma couleur さんが出しているバウムクーヘンのお菓子です。 さすがはスイーツの本場、神戸と言ったところでしょうか。

サイバーセキュリティ技術のハニーポットと同名のハニーポットが存在していたことに衝撃を受けました。

f:id:UltraBirdTech:20210915185926j:plain
ナッツ味

f:id:UltraBirdTech:20210915185942j:plain
レモン味

試しにレモン味を食べてみたのですが、バウムクーヘンを基礎として中に生クリームとレモン味のクリームが入っておりミニケーキのような感覚で食べることができます。レモン味もとても良い感じです!すごい幸せなひと時です。。。

実はハニーポットを探すの苦労しました。

2021年9月、兵庫県は緊急事態宣言中でした。

本店である元町駅から数分歩いたところにある本店に行ったところ緊急事態宣言のためcloseの看板が・・・ 公式サイトをみたところ兵庫県内各地のお土産ショップで売っているとのことだったので、神戸ないのお土産ショップに複数出向いたところハニーポットをクッキーにしたものがお土産として売られておりました。(違うこれじゃない・・・)今回目的のバームクーヘンのハニーポットを探すのに非常に苦労しました。

そして最後に一縷の望みをかけて新幹線に乗る前の新神戸駅で、ハニーポットを発見! 無事にハニーポットを入手することができました。(写真は新幹線の中で撮影したもの)

f:id:UltraBirdTech:20210915185809j:plain

通販あります

とはいえ、兵庫県まで買いに行ったのですが、実際は通販でも全国各地から取り寄せ可能とのことなので、もし興味ある人がいれば、そちらからどうぞ。 わざわざ兵庫のお土産屋さんを回る必要はないようです。

まとめ

ハニーポット美味しい。 そして、そろそろハニーポットを復活させようかなと思っています。

【備忘録】フリーの脆弱性スキャナーNiktoの備忘録

最近、仕事でNiktoを使うようになっているので、Niktoに対しての備忘録。

Niktoとは?

github.com

概要①(英語)

Nikto is an Open Source (GPL) web server scanner which performs comprehensive tests against web servers for multiple items, including over 6700 potentially dangerous files/programs, checks for outdated versions of over 1250 servers, and version specific problems on over 270 servers. It also checks for server configuration items such as the presence of multiple index files, HTTP server options, and will attempt to identify installed web servers and software. Scan items and plugins are frequently updated and can be automatically updated. Nikto is not designed as a stealthy tool. It will test a web server in the quickest time possible, and is obvious in log files or to an IPS/IDS. However, there is support for LibWhisker's anti-IDS methods in case you want to give it a try (or test your IDS system).

概要①(日本語訳(基本はGoogle翻訳))

NiktoはオープンソースGPL)ライセンスで作成されている、Webサーバースキャナーであり、6700を超える潜在的に危険なファイル/プログラムを含む複数のアイテムについて、Webサーバーに対して包括的なテストを実行し、1250を超えるサーバーの古いバージョンをチェックし、270を超えるサーバーでバージョン固有の問題をチェックします。また、複数のインデックスファイルの存在、HTTPサーバーオプションなどのサーバー構成項目をチェックし、インストールされているWebサーバーとソフトウェアの識別を試みます。スキャンアイテムとプラグインは頻繁に更新され、自動的に更新できます。

概要①の要約

要約すると、Niktoは一言で言うとWebサーバースキャナー。 オープンソース(GPL)ライセンスで作成されているOSS。 6700を超える危険なファイル、プログラムなどのアイテムを知っており、それらの知見をもとにWebサーバーに対して、それらの危険なファイル、プログラムが存在しないかの包括的なテストを実行することができます。

6700というのは、危険なファイルの定義は定かではないが、他のものとして多種多様なWebサーバー(Apache, Nginx)、プログラム言語(PHPJava・・・)、Webフレームワーク(lalavel, Struts)、CMS(WordPressDrupal)などのデフォルトの公開設定しているファイルが公開状態になっていないかの検査パターンが用意されているという認識でいいだろう。

概要②(英語)

Not every check is a security problem. There are some items that are "info only" type checks that look for things that may not have a security flaw, but Pentester may not know are present on the server. These items are usually marked appropriately in the information printed. There are also some checks for unknown items which have been seen scanned for in log files. Not every check is a security problem. There are some items that are "info only" type checks that look for things that may not have a security flaw, but Pentester may not know are present on the server. These items are usually marked appropriately in the information printed. There are also some checks for unknown items which have been seen scanned for in log files.

概要②(基本はGoogle翻訳))

Niktoはステルスツールとして設計されていません。可能な限り迅速にWebサーバーをテストし、ログファイルまたはIPS / IDSで明らかになります。ただし、試してみたい(またはIDSシステムをテストしたい)場合に備えて、LibWhiskerのアンチIDSメソッドがサポートされています。 すべてのチェックがセキュリティの問題であるとは限りません。セキュリティ上の欠陥がない可能性のあるものを探す「情報のみ」のタイプのチェックである項目がいくつかありますが、Pentesterはサーバーに存在することを知らない可能性があります。これらのアイテムは通常、印刷される情報に適切にマークされています。ログファイルでスキャンされた不明なアイテムのチェックもいくつかあります。

概要②の要約

Niktoはステルスツールではない。なので、サーバーを監視している人に気づかれないように扱うようなツールではない。以前、SOC研修を受けた時、SIEMでサーバーへのリクエスト量を計測していたら、急激にリクエスト数が跳ね上がって監視役の人があたふたしたのを思い出した。確か、サーバーへ大量アクセスするときの手法としてNiktoを使ったって講師の人言っていたなぁ。。。 その時はスモークスクリーンとして使用されていて、Niktoのアクセスで監視役があたふたしているときに、本当にやりたい攻撃(XSSやSQLi)などを入れ込んでいた記憶。

Niktoのゴール(英語)

The goal of the project is to examine a web server to find potential problems and security vulnerabilities, including: ・Server and software misconfigurations ・Default files and programs ・Insecure files and programs ・Outdated servers and programs ・Pointers to lead a human tester to better manual testing Nikto is built on LibWhisker2 (by Rain Forest Puppy) and can run on any platform which has a Perl environment. It supports SSL, proxies, host authentication, attack encoding and more.

Niktoのゴール(基本はGoogle翻訳))

Niktoの目標は、Webサーバーを調べて、次のような潜在的な問題とセキュリティの脆弱性を見つけることです。 ・サーバーとソフトウェアの構成ミス ・デフォルトのファイルとプログラム ・安全でないファイルとプログラム ・古いサーバーとプログラム 人間のテスターをより良い手動テストに導くためのポインター Niktoは(Rain Forest Puppyによる)LibWhisker2上に構築されており、Perl環境を持つ任意のプラットフォームで実行できます。 SSL、プロキシ、ホスト認証、攻撃エンコーディングなどをサポートします。

Niktoのゴールの要約

引用形式では箇条書きが崩れてしまっているが、箇条書きの部分は下記。

  • サーバーとソフトウェアの構成ミス
  • デフォルトのファイルとプログラム
  • 安全でないファイルとプログラム
  • 古いサーバーとプログラム

人間のミスによる意図せず公開してしまっているファイルやディレクトリを見つけることや、安全ではないプログラムなどを見つけることができる。また、Perl環境で動いているので、Niktoを動かす際にPerl環境が必要な場合が存在する。

基本的なオプション

   Options:
       -ask+               Whether to ask about submitting updates
                               yes   Ask about each (default)
                               no    Don't ask, don't send
                               auto  Don't ask, just send
       -Cgidirs+           Scan these CGI dirs: "none", "all", or values like "/cgi/ /cgi-a/"
       -config+            Use this config file
       -Display+           Turn on/off display outputs:
                               1     Show redirects
                               2     Show cookies received
                               3     Show all 200/OK responses
                               4     Show URLs which require authentication
                               D     Debug output
                               E     Display all HTTP errors
                               P     Print progress to STDOUT
                               S     Scrub output of IPs and hostnames
                               V     Verbose output
       -dbcheck           Check database and other key files for syntax errors
       -evasion+          Encoding technique:
                               1     Random URI encoding (non-UTF8)
                               2     Directory self-reference (/./)
                               3     Premature URL ending
                               4     Prepend long random string
                               5     Fake parameter
                               6     TAB as request spacer
                               7     Change the case of the URL
                               8     Use Windows directory separator (\)
                               A     Use a carriage return (0x0d) as a request spacer
                               B     Use binary value 0x0b as a request spacer
        -Format+           Save file (-o) format:
                               csv   Comma-separated-value
                               htm   HTML Format
                               msf+  Log to Metasploit
                               nbe   Nessus NBE format
                               txt   Plain text
                               xml   XML Format
                               (if not specified the format will be taken from the file extension passed to -output)
       -Help              Extended help information
       -host+             Target host
       -IgnoreCode        Ignore Codes--treat as negative responses
       -id+               Host authentication to use, format is id:pass or id:pass:realm
       -key+              Client certificate key file
       -list-plugins      List all available plugins, perform no testing
       -maxtime+          Maximum testing time per host
       -mutate+           Guess additional file names:
                               1     Test all files with all root directories
                               2     Guess for password file names
                               3     Enumerate user names via Apache (/~user type requests)
                               4     Enumerate user names via cgiwrap (/cgi-bin/cgiwrap/~user type requests)
                               5     Attempt to brute force sub-domain names, assume that the host name is the parent domain
                               6     Attempt to guess directory names from the supplied dictionary file
       -mutate-options    Provide information for mutates
       -nointeractive     Disables interactive features
       -nolookup          Disables DNS lookups
       -nossl             Disables the use of SSL
       -no404             Disables nikto attempting to guess a 404 page
       -output+           Write output to this file ('.' for auto-name)
       -Pause+            Pause between tests (seconds, integer or float)
       -Plugins+          List of plugins to run (default: ALL)
       -port+             Port to use (default 80)
       -RSAcert+          Client certificate file
       -root+             Prepend root value to all requests, format is /directory
       -Save              Save positive responses to this directory ('.' for auto-name)
       -ssl               Force ssl mode on port
       -Tuning+           Scan tuning:
                               1     Interesting File / Seen in logs
                               2     Misconfiguration / Default File
                               3     Information Disclosure
                               4     Injection (XSS/Script/HTML)
                               5     Remote File Retrieval - Inside Web Root
                               6     Denial of Service
                               7     Remote File Retrieval - Server Wide
                               8     Command Execution / Remote Shell
                               9     SQL Injection
                               0     File Upload
                               a     Authentication Bypass
                               b     Software Identification
                               c     Remote Source Inclusion
                               x     Reverse Tuning Options (i.e., include all except specified)
       -timeout+          Timeout for requests (default 10 seconds)
       -Userdbs           Load only user databases, not the standard databases
                               all   Disable standard dbs and load only user dbs
                               tests Disable only db_tests and load udb_tests
       -until             Run until the specified time or duration
       -update            Update databases and plugins from CIRT.net
       -useproxy          Use the proxy defined in nikto.conf
       -Version           Print plugin and database versions
       -vhost+            Virtual host (for Host header)
              + requires a value

実際にやってみる

コマンド

$ perl nikto.pl -h 127.0.0.1 -p 8000 -nolookup -Format txt -o 

なんかPerlが既に入っていたのでPerlコマンドで実行。

ローカルにDjangoで簡易的なWebアプリを作成し試行しました。なので、portも通常のhttp/https通信で使われる80や443ではなく、Webアプリを立ち上げているportを指定。フォーマットとしては、txt形式で出力されるように指定しました。

実行結果(ターミナル)

$ perl nikto.pl -h 127.0.0.1 -p 8000 -nolookup -Format txt -o test_2021_0717_valtan_text.txt
- ***** SSL support not available (see docs for SSL install) *****
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          127.0.0.1
+ Target Hostname:    127.0.0.1
+ Target Port:        8000
---------------------------------------------------------------------------
+ SSL Info:        Subject:  
                   Ciphers:  
                   Issuer:   
+ Start Time:         2021-07-18 15:50:01 (GMT9)
---------------------------------------------------------------------------
+ Server: WSGIServer/0.2 CPython/3.7.2
+ The site uses SSL and the Strict-Transport-Security HTTP header is not defined.
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Hostname '127.0.0.1' does not match certificate's names: 
+ OSVDB-17113: /SilverStream: SilverStream allows directory listing
+ ///etc/hosts: The server install allows reading of any system file by adding an extra '/' to the URL.
+ Server banner changed from 'WSGIServer/0.2 CPython/3.7.2' to 'WSGIServer/0.2 Python/3.7.2'
+ /wp-content/themes/twentyeleven/images/headers/server.php?filesrc=/etc/hosts: A PHP backdoor file manager was found.
+ /wordpress/wp-content/themes/twentyeleven/images/headers/server.php?filesrc=/etc/hosts: A PHP backdoor file manager was found.
+ /wp-includes/Requests/Utility/content-post.php?filesrc=/etc/hosts: A PHP backdoor file manager was found.
+ /wordpress/wp-includes/Requests/Utility/content-post.php?filesrc=/etc/hosts: A PHP backdoor file manager was found.
+ /wp-includes/js/tinymce/themes/modern/Meuhy.php?filesrc=/etc/hosts: A PHP backdoor file manager was found.
+ /wordpress/wp-includes/js/tinymce/themes/modern/Meuhy.php?filesrc=/etc/hosts: A PHP backdoor file manager was found.
+ /assets/mobirise/css/meta.php?filesrc=: A PHP backdoor file manager was found.
+ /login.cgi?cli=aa%20aa%27cat%20/etc/hosts: Some D-Link router remote command execution.
+ /shell?cat+/etc/hosts: A backdoor was identified.
+ 8078 requests: 0 error(s) and 14 item(s) reported on remote host
+ End Time:           2021-07-18 15:51:13 (GMT9) (72 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

フィイルとしてアウトプットされたのも上記と同じ内容が出力されていた。

内容を見てみると、ヘッダーにStrict-Transport-Securityがついていないとの指摘が。ローカルの開発なので勘弁・・・

気になるのが、Djangoのプロジェクトなのにwordpressに関連するwp-includeswordpressなどが検知されていること。ローカル環境、変な汚れ方しているのかな・・・わからん。

【おまけ】実行結果(サーバー側)

当たり前のようだが、Niktoから大量のリクエストを受け付けていることを確認。

一部抜粋。nginxのファイルや、Docker、GitHubのReadmeなど考えられるありとあらゆる公開されていると思われるファイルへのリクエストを投げて404が返ってくる(ファイルが存在しない)ことを確認している。

[18/Jul/2021 06:51:13] "GET /nginx_status HTTP/1.1" 404 2089
Not Found: /Dockerfile
[18/Jul/2021 06:51:13] "GET /Dockerfile HTTP/1.1" 404 2083
Not Found: /cdn-cgi/trace
[18/Jul/2021 06:51:13] "GET /cdn-cgi/trace HTTP/1.1" 404 2092
Not Found: /v1/tasks
[18/Jul/2021 06:51:13] "GET /v1/tasks HTTP/1.1" 404 2077
Not Found: /v2/tasks
[18/Jul/2021 06:51:13] "GET /v2/tasks HTTP/1.1" 404 2077
Not Found: /v3/tasks
[18/Jul/2021 06:51:13] "GET /v3/tasks HTTP/1.1" 404 2077
Not Found: /v4/tasks
[18/Jul/2021 06:51:13] "GET /v4/tasks HTTP/1.1" 404 2077
Not Found: /.dockerignore
[18/Jul/2021 06:51:13] "GET /.dockerignore HTTP/1.1" 404 2092
Not Found: /tmui/login.jsp/..;/tmui/locallb/workspace/fileRead.jsp
[18/Jul/2021 06:51:13] "GET /tmui/login.jsp/..;/tmui/locallb/workspace/fileRead.jsp?fileName=/etc/hosts HTTP/1.1" 404 2237
Not Found: /
[18/Jul/2021 06:51:13] "GET / HTTP/1.1" 404 2035
Not Found: /var/
[18/Jul/2021 06:51:13] "GET /var/ HTTP/1.1" 404 2065
Not Found: /var/log/
[18/Jul/2021 06:51:13] "GET /var/log/ HTTP/1.1" 404 2077
Not Found: /etc/
[18/Jul/2021 06:51:13] "GET /etc/ HTTP/1.1" 404 2065
Not Found: /.ftpconfig
[18/Jul/2021 06:51:13] "GET /.ftpconfig HTTP/1.1" 404 2083
Not Found: /.remote-sync.json
[18/Jul/2021 06:51:13] "GET /.remote-sync.json HTTP/1.1" 404 2104
Not Found: /.vscode/ftp-sync.json
[18/Jul/2021 06:51:13] "GET /.vscode/ftp-sync.json HTTP/1.1" 404 2116
Not Found: /.vscode/sftp.json
[18/Jul/2021 06:51:13] "GET /.vscode/sftp.json HTTP/1.1" 404 2104
Not Found: /deployment-config.json
[18/Jul/2021 06:51:13] "GET /deployment-config.json HTTP/1.1" 404 2119
Not Found: /ftpsync.settings
[18/Jul/2021 06:51:13] "GET /ftpsync.settings HTTP/1.1" 404 2101
Not Found: /sftp-config.json
[18/Jul/2021 06:51:13] "GET /sftp-config.json HTTP/1.1" 404 2101

まとめ

  • NiktoはWebサーバーのスキャナー
  • 大量の多種多様な検査パターンのリクエストを投げて、意図しないファイルが公開されていないかを確認できる
  • 案外使ってみて楽だった

ドキュメントが公式で非常によくまとまっており、とても分かりやすかった。これを経たとして、Niktoマスターになったわけではないが、もう少し業務で扱えるようになりたいなぁ・・・