Home > Articles > Security > Network Security

This chapter is from the book

This chapter is from the book

Activity Reconstruction

The incident timeline developed thus far in your investigation will allow you to limit the scope of the activity reconstruction. Table 11.1 summarizes the incident timeline you have created.

Table 11.1. Incident Timeline

Time

Event

Source

2008-08-31 15:27:09.50

Brute-force attack initiated

192.168.1.20

2008-08-31 15:31:35.24

Attacker gained unauthorized access to the PROD-SQL05 server using the MSmith login account

MSmith login

2008-08-31 15:32:41.367

Temporary object #09DE7BCC was created within Tempdb database

MSmith login

2008-08-31 15:36:34.42

Attacker reconnects to PROD-SQL05

MSmith login

2008-08-31 15:38:15.31

Attacker reconnects to PROD-SQL05

MSmith login

2008-08-31 15:41:55.060

IllB3back table was created within Master database

MSmith login

2008-08-31 15:43:23.74

Attacker reconnects to PROD-SQL05

MSmith login

2008-08-31 15:46:03.340

EASYACCESS login created

MSmith login

A key method of identifying past activity is reviewing command execution. Thus the next step in your investigation focuses on identifying the commands executed by the attacker on the SQL Server during his or her period of unauthorized access. The first artifact you analyze is server state information in an effort to determine details about the intruder's actions.

Server State

The server state artifact captures the current state of active connections and processes on a server. It includes a wealth of information, ranging from active user connections to database processes executing in the background to the last command executed by each connected user. Within WFT, you select the Active Connections | Connections and Sessions links to view active sessions on the victim system at the time of automated artifact collection. After reviewing the data on these pages, you conclude that the attacker has disconnected from the system: The MSmith login account does not appear in the list of actively connected users.

The next artifact you analyze is the plan cache, which may have cached the attacker's previously executed database statements.

Plan Cache

Reviewing the plan cache enables you to pinpoint anomalous entries that may be associated with the attacker. Although plan cache entries cannot be associated with a specific user, the process of associating plan cache entries to other database activity can map actions to a specific SQL Server login or database user. As your next move, you run the following syntax within the INV_308_Scenario database to return a list of plan cache entries that were cached during the scope of the incident:

SELECT * from plch_data order by convert(datetime, creation_time) desc

A snippet of the results returned appears in Figure 11.9.

Figure 11.9

Figure 11.9 A snippet of the plan cache entries cached during the scope of the incident

Your first search of the plan cache was done in an effort to identify which statement forced the creation of the #09DE7BCC temporary table within the Tempdb database. Because the creation of this object has already been mapped back to the MSmith login, you can place the attacker at a specific cache entry. This information serves as a starting point for identifying past activity as well as future activity not yet discovered.

As shown earlier in Table 11.1, the #09DE7BCC table was created at 2008-08-31 15:32:41.367. Using this time to the second, you perform a search of the plan cache entries in the hopes of finding a cached statement that was the source of the temporary table creation:

SELECT * FROM PLCH_Data WHERE CAST ([Creation_time] AS DATETIME) >= cast ('2008-08-31
15:32:41.000' AS DATETIME) AND CAST ([Creation_time] AS DATETIME) <= CAST ('2008-08-31
15:32:41.999' AS DATETIME) or CAST ([Last_execution_time] AS DATETIME) >= cast ('2008-
08-31 15:32:41.000' AS DATETIME) AND CAST ([Last_execution_time] AS DATETIME) <= CAST
('2008-08-31 15:32:41.999' AS DATETIME) order by last_execution_time desc

Figure 11.10 shows a snippet of the results produced by this query.

Figure 11.10

Figure 11.10 Plan cache entries created or executed at 2008-08-31 15:32:41

At first glance, you notice that the sys.sp_helpdb procedure was created multiple times—when a stored procedure is cached, its definition is displayed within the plan cache after execution. In close proximity to the sp_helpdb execution are four statements that update the temporary table #spdbdesc. The naming convention of this table seems to be related to sp_helpdb, so you select the object definition of sp_helpdb for further analysis. You gather the definition for sp_helpdb from server SP2, which runs SQL Server 2005. This version of SQL Server was the same major and minor release used on the victim, based on the server information obtained from the DB Configuration | SQL Server Info link within WFT.

On the trusted instance, you execute the following syntax:

SELECT OBJECT_DEFINITION (OBJECT_ID ('sys.sp_helpdb'))

Within the returned definition, you identify the statement that creates the #spdbdesc table. You note the following snippet of code, which shows the syntax within the sp_helpdb procedure that creates the temporary table logged under the transaction executed by the MSmith account:

create table #spdbdesc  (   dbname sysname,   owner sysname null,   created
nvarchar(11),   dbid smallint,   dbdesc nvarchar(600) null,   dbsize  nvarchar(13)
null,   cmptlevel tinyint  )      /*  **  If no database name given, get 'em all.  */

Although plan cache entries cannot be directly mapped back to a user or SID as operations within the transaction log can be, you map the executed statement within the plan cache to the resulting table creation data logged within the transaction log; this mapping again leads back to the MSmith SID. This discovery proves that the MSmith account executed the sp_helpdb procedure once the user gained access to the database server. Because sp_helpdb provides information about the databases on a SQL Server instance, you suspect that the attacker executed this procedure to learn the structure of the database server to which he or she just gained access. With an idea of the attacker's objective, you execute the following query, which allows you to view all plan cache entries in descending order by last_execution_time:

select * from plch_data order by convert(datetime, last_execution_time )desc

Once this query is executed, database reconnaissance-related entries are noted in the plan cache. These entries are highlighted in Figure 11.11.

Figure 11.11

Figure 11.11 Database reconnaissance-related plan cache entries

The transaction execution history suggests that database reconnaissance activity has, indeed, taken place. Database reconnaissance typically involves the execution of vague statements that return a manageable amount of data and allow the user to sort out the information he or she needs. Attackers are typically unfamiliar with the structure of a database, but they must be careful when attempting to learn it because that effort may attract attention or simply take time away from their primary objective.

Within the results captured in Figure 11.11. some fields have been reordered due to formatting limitations. By beginning at row 30 and working backward, you identify the following actions believed to be executed by the unauthorized user:

  • Row 30: Queried the sys.syslogins view within the Master database to get an understanding of the accounts on the SQL Server instance. Execution of this statement within the Master database was identified by the dbid value of 1, which maps to the Master database (as seen by executing the DB Objects & Users | Database link within WFT).
  • Rows 29–16: Executed sp_helpdb to learn about the databases on the SQL Server instance (which you proved earlier). Because sp_helpdb is a system object that can be executed, it is launched from the Resource database (database ID 32767).
  • Row 13: Switched database context to the OnlineSales database after the user received the results from sp_helpdb as identified by the dbid value of 5 in the next database reconnaissance-related query.
  • Row 13: Queried the sys.sysusers view to learn about the database users within the OnlineSales database.
  • Row 11: Queried sysobjects with a where type = 'U' clause, which returns a listing of all tables within the database.
  • Row 10: Executed a select statement against the orderhistory table, which would have been listed within the previous sysobjects results.
  • Rows 9–5: Executed multiple queries against multiple views in search of password or encryption key–related information, perhaps in an attempt to decrypt the data within the orderhistory table believed to be encrypted by the attacker.
  • Row 4: After the reconnaissance, executed the sp_password procedure, as identified by its definition being recorded as a statement.

Even your artifact collection actions are logged within the plan cache. Row 2 from the results captured in Figure 11.11 shows the execution of the IR scripts used during incident response and, therefore, can be ignored.

Other entries within the plan cache involve updates to the Orders table. However, all entries affecting the Orders table within the transaction log were executed by the OSApp login, which is also interactively logged into the system. (This fact can be verified by reviewing the information within Active Connections | Connections and Sessions links.)

You now conclude that the SELECT INTO statement executed by the unauthorized user is not resident in the cache, either because the database engine did not cache it or because it was evicted prior to its preservation.

This step completes your plan cache analysis. Your final artifact to analyze is the active VLFs obtained from the OnlineSales and Master databases of the victim system.

Active VLFs

To begin analysis of active VLF data, you execute the following syntax within the database to return a summary of all transactions performed by SID 0x501AEC871FD432488B4 A487B06C61505, which belongs to the MSmith login:

SELECT DISTINCT [TRANSACTION NAME], [BEGIN TIME], [current lsn] FROM AVLF_TLOG where
[TRANSACTION ID] IN (SELECT distinct [TRANSACTION ID] FROM AVLF_TLOG WHERE [TRANSACTION
SID] = '0x501AEC871FD432488B4A487B06C61505') and [transaction name] <> 'NULL' order by
[current lsn]

When this syntax is run, you receive the results captured in Figure 11.12.

Figure 11.12

Figure 11.12 Summary of all transactions performed by the suspect SID

You immediately discount the two CREATE STATISTICS transactions, which occurred prior to the unauthorized user gaining access to the database server. Instead, you focus on the entries highlighted in Figure 11.12. To obtain more details about these transactions, you execute the following slightly modified query, which returns 269 rows:

SELECT [database], [transaction ID], [transaction name], [operation], [allocunitname],
[begin time], [end time], spid, [transaction sid] FROM AVLF_TLOG where [TRANSACTION ID]
IN (SELECT DISTINCT [TRANSACTION ID] FROM AVLF_TLOG WHERE [TRANSACTION SID] =
'0x501AEC871FD432488B4A487B06C61505')

(Note: The preceding query and its results will be referred to several times throughout the rest of this chapter as "the detailed transaction summary results.")

To see the logical progression of the attacker's actions on the database, you step through the detailed transaction summary results in sequence by transaction ID, beginning with transaction 2723.

You first analyze transaction ID 2723, a SELECT INTO statement located within row 21 of the detailed transaction summary results. Figure 11.13 contains a snippet of this transaction.

Figure 11.13

Figure 11.13 Snippet of transaction ID 2723

Unfortunately, the SELECT INTO statement did not record the affected table within the Master database in the AllocUnitName field. Nevertheless, you examine the date and time when the transaction was committed. Matching this information to an object within the Master database will allow you to identify the created table. Transaction 2723 began on 2008/08/31 15:41:55:060. You develop the following syntax to compare the time the transaction was initiated against the object creation times within the DOBJ_Data table, which contains all objects and their associated creation and last update times on the victim server:

SELECT * from dobj_data where convert(datetime, create_date) = convert(datetime, '2008-08-31 15:41:55:060')

When this query is run, it returns the IllB3back table. This result reaffirms your earlier investigation finding. A snippet of the results appears in Figure 11.14. Because the original plan cache entry could not be recovered during your investigation, the other table involved in the SELECT INTO statement cannot be identified.

Figure 11.14

Figure 11.14 Database objects created at 2008/08/31 15:41:55:060

The second statement executed by the unauthorized user is transaction ID 2724, which is located on row 100 of the previous detailed transaction summary results. A snippet of transaction ID 2724 within these results is shown in Figure 11.15.

Figure 11.15

Figure 11.15 Snippet of transaction ID 2724

Stepping through the various operations within this transaction, you focus on row 240. It reveals that the transaction was aborted at 2008/08/31 15:43:16:570, as shown in Figure 11.16. This operation would have reverted the copying of data from the source table to the destination IllB3Back table.

Figure 11.16

Figure 11.16 An aborted transaction

Transaction ID 2725 was executed by the database engine in response to the SELECT INTO statement executed via transaction 2724. Transaction 2724 began allocating data pages for the IllB3back table before it was aborted. Figure 11.17 shows the IllB3back table referenced under the allocation unit field of transaction 2725.

Figure 11.17

Figure 11.17 The IllB3back table referenced under the allocation unit field of transaction 2725

As seen in Figure 11.18, transaction ID 2726 related to the alteration of a login. This transaction shows that a login was modified, but that the operations were immediately aborted. This behavior is usually associated with a validation check performed on the server, which was not meant to proceed with the login alteration.

Figure 11.18

Figure 11.18 Snippet of an aborted alter login operation

In the next part of your investigation, you develop the following syntax to query the plan cache and identify cached statements that were created or used at the same time of the transaction to the second:

SELECT * FROM PLCH_Data WHERE CAST ([Creation_time] AS DATETIME) >= cast ('2008-08-31
15:45:15.000' AS DATETIME) AND CAST ([Creation_time] AS DATETIME) <= CAST ('2008-08-31
15:45:15.999' AS DATETIME) or CAST ([Last_execution_time] AS DATETIME) >= cast ('2008-
08-31 15:45:15.000' AS DATETIME) AND CAST ([Last_execution_time] AS DATETIME) <= CAST
('2008-08-31 15:45:15.999' AS DATETIME) order by last_execution_time desc

When this code is executed, the results (captured in Figure 11.19) reveal that the cache plan entry for sp_password was created at the same time to the second as the ALTER LOGIN operation within the transaction log.

Figure 11.19

Figure 11.19 Plan cache entries created or last executed at Database objects created at 2008-08-31 15:45:15

The creation time shown in Figure 11.19 is the date and time the entry was cached, and the last_execution_time is the last time the plan entry was used by a database user. Reviewing your log summary, you note that two additional ALTER LOGIN operations were executed under transactions 2727 and 2728; these operations are found in rows 244 and 247 within the detailed transaction summary results (see Figure 11.20).

Figure 11.20

Figure 11.20 Two additional ALTER LOGIN operations executed under transactions 2727 and 2728

In Figure 11.20, the ALTER LOGIN operation was executed under transaction ID 2727 (row 253) but immediately failed after initiation. This mirrors transaction 2726's result, which indicates another password reset-related failure. Transaction 2728, however, executed successfully, as evidenced by the LOP_COMMIT_XACT operation logged at 2008/08/31 15:45:43:797.

You develop the following syntax to compare transaction 2726's commit time with logins created or updated, to the second, during the successful account update performed by transaction 2728:

SELECT * FROM LOGN_SQL WHERE CAST ([UPDATEDATE] AS DATETIME) >= cast ('2008/08/31
15:45:43:000' AS DATETIME) AND CAST ([UPDATEDATE] AS DATETIME) < CAST ('2008/08/31
15:45:43:999' AS DATETIME)

When this syntax is run, it produces the results shown in Figure 11.21. It appears that the MSmith account was updated in accordance to the transaction log entry to the second. This finding also allows you to reconfirm Mike's statement from earlier during the investigation—namely, that he could not gain access to his account earlier in the day.

Figure 11.21

Figure 11.21 Logins updated at 2008/08/31 15:45:43

Transaction 2729 (row 254) is a CREATE statement that was analyzed earlier in your investigation. It led to your discovery that the MSmith account created the EASYACESS account within the database server.

No other notable findings were identified in the analysis of the other artifacts collected from the victim system.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020