23
Attacking PLCs by PLC in deep CHENG LEI GEWU LAB@NSFOCUS [email protected]

Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

  • Upload
    others

  • View
    55

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

Attacking PLCs by PLC in deep

CHENG LEI

GEWU LAB@NSFOCUS

[email protected]

Page 2: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400
Page 3: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

Introduction of PLCs Attacking

Siemens PLC Protocol

Schneider PLC Protocol

Rockwell AB PLC Protocol

Attacking PLCs by PLC

Page 4: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400
Page 5: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

• Replay attacks have been widely used in PLC attacks.

• Get the communication sequence packets with the help of Wireshark

Page 6: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

S7-300

• S7-200,S7-300,S7-400 using the S7Comm protocol

S7-1500

S7-1200

• S7-1200v3.0 using the early S7CommPlus protocol

• S7-1200v4.0, S7-1500 using the current encrypted S7CommPlus protocol

Page 7: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400
Page 8: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

• The current S7CommPlus protocol including the S7CommPlus Connection packets and S7CommPlus Function packets has a similar structure.

• 1. First Connection Setup Request• 2. Frist Connection Setup Response• 3. Second Connection Setup Request• 4. Function Packet—Stop PLC

Page 9: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

• Using reverse debugging techniques, we found these encryption is calculated by TIA Portal through a file named OMSp_core_managed.dll

1. Connection packet encryption

Input parameter for this encryption is a random value array generated by

the PLC in the first connection response packet.

Page 10: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

Using XOR (we call this Encryption1), the first encryption can be calculated with the input

parameter Value Array.

Encryption1 First EncryptionValue Array

(1) First encryption in the connection packet

Page 11: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

(2)Second encryption in the connection packet

Using the result of the first encryption as input parameter, the second encryption is

calculated through a more complex Siemens-private algorithm.

Encryption2 Second EncryptionFirst Encryption

Page 12: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

2. Function packet encryption

A fixed field array with Session ID is the input parameter. A complex algorithm (we call

this Encryption3) is used to calculated the encryption result as follow:

Encryption3 Function Encryption

ConstanArray

(with Session ID)

Page 13: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

ModBus/TCP

Port: 502

Function Code : 90

Unity Pro

Page 14: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

1. Get Session ID2. Run PLC Packet3. Stop PLC Packet4. Write DO Value

For DO Value Write Packet, the first byte is the Session ID, the second byte is the function code, 0x50 means write digital value, the 22nd byte is the address and the 29th byte is the value.

Page 15: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

EtherNet/IP&CIP

Port: 44818

RSLogix

Page 16: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

1. EtherNet/IP Connection Packet

The EtherNet/IP connection is shown above, it has 4 ENIP packets, with the “Command” 0x0001(Unknown),

0x0004(ListServices), 0x0064(ListInterfaces) and 0x0065(Register Session). There is a Session ID in the

response packet of Register Session Request packet, as shown below

2. CIP Connection Packet

When EtherNEt/IP successfully connected, then send a CIP Connection Manager packet, as shown below

After sending the CIP CM request packet, the PLC will send a CIP CM response packet, as shown below

The O->T Network Connection will play the part as Session ID in the following CIP function packet

Following the CIP connection Manager connection is the CIP connection, there

are totally 6 packets in this CIP connection procedure.

Every Connection packet use the O->T Network Connection ID and Originator

Serial Number from CIP Connection Manager Response packet, as shown in

the red box and blue box of the figure below. Every CIP Packet use Sequence

Count as the sequence of the communication, as shown in the green box below.

Page 17: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

3. Run PLC packet

The red box is the O->T

Network Connection ID and the

blue box is the Originator Serial

Number both in the CIP

Connection Manager

Response packet. The green

box is the Sequence Count.

The yellow one “0x55, 0x01”is

the run PLC function code.

4. Stop PLC Packet

The red box is the O->T

Network Connection ID

and the blue box is the

Originator Serial Number

both in the CIP Connection

Manager Response packet.

The green box is the

Sequence Count. The

yellow one “0xf1, 0x01”is

the stop PLC function code.

5. Write Digital Value packet

The red box is the O->T

Network Connection ID and the

blue box is the Originator Serial

Number both in the CIP

Connection Manager Response

packet. The green box is the

Sequence Count. The yellow

one is the function code. Purple

one is the address and orange

one is the value.

Page 18: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

• TCP, Port 502, Port 44818

– All Schneider PLCs use port 502 for

TCP communication

– All AB PLCs use port 44818 for TCP

communication

• TCON、TDISCON

– TCON:To establish TCP connection

with other device

– TDISCON:Disconnect the

established TCP connections.

Page 19: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

• TCP

– Using the Modbus protocol and

the CIP protocol to play replay

attack to the PLCs inside the net

• TSEND, TRCV

– TSEND:Send TCP data

– TRCV:Receive TCP data

• Packets message in DB block

– Leave the detecting and attacking

packets message in DB block.

Page 20: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

PLC detection and finally send the PLCs’ information like IP and Port to C&C server.

Page 21: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

Attacking Schneider and AB PLCs.

Page 22: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400
Page 23: Attacking PLCs by PLC in deep - NSFOCUSblog.nsfocusglobal.com/wp-content/uploads/2018/11/... · 2018-11-12 · Attacking PLCs by PLC in deep CHENG LEI ... S7-300 • S7-200,S7-300,S7-400

THANK YOU