Ansune secure operating system covert channel scenario demonstration of the second "recent Access Time channel"

Source: Internet
Author: User

First, the purpose of the experiment

1. Familiar with the operating environment of Ansune safe operating system

2. How to work with covert channels


Ii. contents of the experiment

1. Finish writing, compiling, and executing the Send and receive programs

2. Demonstrates the existence of a covert channel scenario:


III. Experimental process and results
(1) Test preparation

1. Boot to the secure core seclinux before the covert channel is processed

2. Create two users the security category for User_h and User_l,user_h includes user_l security, user_h a security level higher than the user_l security level. In addition, set the user home directory security level is the same as the user security level, the two user home directory discretionary access control permissions, that is, through the chmod command to set their permissions to 0777, allowing U,g,o to read, write and execute.

3. Check the safety of Seclinux:

Advanced users can read low-security files, but they cannot create low-security files or pass information down through copies. Low-level users cannot read high-security files.

(2) Selected covert channel: The most recent access time channel
Channel Name:

Recent Access Time Channel


Channel Type:

Resident Memory Type


Mediation Variables:

St_atime member of data structure stat


Conditions of existence:

When a user process accesses a file, the system kernel updates the last access time for that file. At the same time, the system's security policy allows high-security users to read access to low-security files, while the low-security level can detect such access.


Sender Action:

The sender reads the confidential file and then determines the number of low-level users to access based on the ASIIC code of the current byte of the file's contents.


Accept-Side action:

First identify a set of files that an advanced user can read. Use the system call stat to read the most recent access time information for these files as raw information is recorded. After the advanced users have sent the message, use the system call stat to read the most recent access time information for these files, and compare with the original information to interpret the time record directory with the change of the recent access event as the ASIIC code value.


Noise situation:

The main reason for the noise is that the CPU time slices received by the receiver may not be sufficient.


Bandwidth estimation:

Not less than 30 bits per second.


Treatment measures:

Mainly rely on audit methods.


Tag variables:

Cc_at

(3) Synchronization mechanism

Synchronization is manufactured using sleep (seconds)/usleep (microseconds).

When a process is sleep, it gives control of the CPU to other processes until the sleep time has passed and regain control of the CPU.

This synchronization technique is easy to implement and suitable for presentation.

However, because the process takes different times to send different characters, and the sleep time is fixed and cannot be changed while the program is running, this synchronization inevitably results in wasted time.

(4) Experimental results

As shown, the left side is the sending side at_sender, the right side is the receiving end of At_receiver, the sender from the same directory Sender_text.txt file to obtain the sending data, through the covert channel sent to the receiving end, the receiving end to the data saved to the same directory Receiver_ In the Text.txt file, the data stored in the send-side file is ABCDEFG.





From the content that can be seen receiver_text.txt, it can be seen that the 7 characters ABCDEFG are transmitted correctly.





(5) Source code of the sending side
#include <sys/stat.h> #include <stdio.h> #include <stdlib.h>void accessfiles (int count); void Sendchar (char ch); int main () {<span style= "white-space:pre" ></span>char ch;<span style= "White-space: Pre "></span>file *fp;<span style=" White-space:pre "></span>if ((fp = fopen ("./sender_text.txt ", "R")) = = NULL)//Open file to send <span style= "White-space:pre" ></span>{<span style= "White-space:pre" >< /span>printf ("fopen error.\n"); <span style= "White-space:pre" ></span>exit (0); <span style= " White-space:pre "></span>}<span style=" White-space:pre "></span>while ((ch = fgetc (fp))! = EOF) <span style= "White-space:pre" ></span>{<span style= "White-space:pre" ></span>sendChar (CH); Every 2 seconds each character is sent Ch<span style= "White-space:pre" ></span>sleep (2); <span style= "White-space:pre" > </span>}<span style= "White-space:pre" ></span>accessfiles (128); Synchronize all file access times as the end of the sentKnowledge <span style= "White-space:pre" ></span>fclose (FP);    return 0;} void AccessFiles (int count) {<span style= "white-space:pre" ></span>file *fp;<span style= "White-space: Pre "></span>char name_tag[25];<span style=" White-space:pre "></span>char tmp;<span style=" White-space:pre "></span>int i;<span style=" White-space:pre "></span>for (i = 0; i < count; i++)/ /Read count files before modifying their access time <span style= "White-space:pre" ></span>{<span style= "White-space:pre" >< /span>sprintf (Name_tag, "./tmp/%d.txt", i); <span style= "White-space:pre" ></span>if ((fp = fopen (name_ Tag, "r")) = = NULL) <span style= "White-space:pre" ></span>{<span style= "White-space:pre" ></span >printf ("fopen error.\n"); <span style= "White-space:pre" ></span>exit (0); <span style= "White-space :p Re "></span>}<span style=" white-space:pre "></span>tmp = fgetc (FP); <span style=" White-spaCe:pre "></span>fclose (FP); <span style=" White-space:pre "></span>}}void SendChar (char ch)// The character send function, by creating a CH process, represents the sending character ch, which lasts for 2 seconds {<span style= "White-space:pre" ></span>printf ("Sending char: [%c].\n" , ch); <span style= "White-space:pre" ></span>accessfiles ((int) ch);}

(6) Source code of the receiving end
#include <sys/stat.h> #include <stdio.h> #include <stdlib.h>int bstart = 0;void createfiles (); Char Checkfiles (); Char Receivechar (); void WriteToFile (char ch); int main () {<span style= "White-space:pre" ></span >char ch;<span style= "White-space:pre" ></span>remove ("./receiver_text.txt"); First delete the previously accepted file <span style= "White-space:pre" ></span>createfiles (); Create intermediate file <span style= "White-space:pre" ></span>while (((ch = Receivechar ())! = (char) 0) | | bstart = 0) <spa n style= "White-space:pre" ></span>{//every 2 seconds to accept the character <span style= "White-space:pre" ></span>if ( bstart = = 0) <span style= "White-space:pre" ></span>{<span style= "White-space:pre" ></span> printf ("Not start.\n"); A bstart of 0 indicates that the sending side has not started sending <span style= "White-space:pre" ></span>}<span style= "White-space:pre" ></ Span>else<span style= "White-space:pre" ></span>{<span style= "White-space:pre" ></span> printf ("Write [%c] to file.\n ", ch); Receive send-side send character Ch<span style= "White-space:pre" ></span>writetofile (CH); Write ch to receive file <span style= "White-space:pre" ></span>}<span style= "White-space:pre" &GT;&LT;/SPAN&GT;} <span style= "White-space:pre" ></span>printf ("end.\n"); <span style= "White-space:pre" ></span >return 0;} void Createfiles () {<span style= "white-space:pre" ></span>file *fp;<span style= "White-space:pre" > </span>char name_tag[25];<span style= "White-space:pre" ></span>int i;<span style= "White-space: Pre "></span>for (i = 0; i <; i++)//Because the ASCII code has 128 characters, so 128 files are created here <span style=" White-space:pre "> </span>{<span style= "White-space:pre" ></span>sprintf (Name_tag, "./tmp/%d.txt", i); <span style = "White-space:pre" ></span>if ((fp = fopen (Name_tag, "w+")) = = NULL) <span style= "White-space:pre" ></ Span>{<span style= "White-space:pre" ></span>printf ("fopen error.\n"); <sPan style= "White-space:pre" ></span>exit (0); <span style= "White-space:pre" ></span>}<span Style= "White-space:pre" &GT;&LT;/SPAN&GT;FPUTC (' t ', FP); The file content is "test" <span style= "White-space:pre" &GT;&LT;/SPAN&GT;FPUTC (' e ', FP); <span style= "White-space:pre" > &LT;/SPAN&GT;FPUTC (' s ', FP); <span style= "White-space:pre" &GT;&LT;/SPAN&GT;FPUTC (' t ', FP); <span style= " White-space:pre "></span>fclose (FP); <span style=" White-space:pre "></span>}}char checkFiles () {<span style= "white-space:pre" ></span>struct stat buf;<span style= "White-space:pre" ></span >int result;<span style= "White-space:pre" ></span>int old_time_int = -1;<span style= "White-space: Pre "></span>int time_int;<span style=" White-space:pre "></span>char Name_tag[25];<span Style= "White-space:pre" ></span>char ch;<span style= "White-space:pre" ></span>int I;<span Style= "White-space:pre" ></span>for (i = 0;I < 128; i++) <span style= "White-space:pre" ></span>{<span style= "White-space:pre" ></span>sprintf ( Name_tag, "./tmp/%d.txt", i); <span style= "white-space:pre" ></span>result = Stat (Name_tag, &buf); Get file information into buf <span style= "White-space:pre" ></span>if (Result! = 0) <span style= "White-space:pre" > </span>{<span style= "White-space:pre" ></span>printf ("Checkfiles error.\n"); <span style= " White-space:pre "></span>}<span style=" White-space:pre "></span>else<span style=" White-space:pre "></span>{<span style=" white-space:pre "></span>time_int = buf.st_atime;// Gets the access time of the file <span style= "White-space:pre" ></span>//printf ("File: [%s], access: [%d].\n], Name_tag _int); <span style= "White-space:pre" ></span>if (old_time_int! =-1 && old_time_int-time_int > 1) When the current post-file access time is greater than 1 seconds, the previous file is the file that the sender accessed <span style= "White-space:pre" ></span>{<Span style= "White-space:pre" ></span>ch = (char) i;<span style= "White-space:pre" ></span>printf ( "File: [%s], Access time: [%d], previous File acces time: [%d].\n", Name_tag, Time_int, old_time_int); <span style= "whit E-space:pre "></span>printf (" Updated file: [%d], receiving char: [%c].\n ", I, ch); <span style=" White-space: Pre "></span>bstart = 1; At this point the send has started, waiting to trigger send end flag <span style= "White-space:pre" ></span>return ch;<span style= "White-space:pre" ></span>}<span style= "White-space:pre" ></span>old_time_int = Time_int;<span style= " White-space:pre "></span>}<span style=" White-space:pre "></span>}<span style=" White-space: Pre "></span>return 0;} Char Receivechar () {<span style= "White-space:pre" ></span>sleep (2);//Receive characters once every 2 seconds <span style= " White-space:pre "></span>return checkfiles ();} void WriteToFile (char ch)//write ch to receive file {<span style= "White-space:pre" ></span>filE *fp;<span style= "White-space:pre" ></span>if ((fp = fopen ("./receiver_text.txt", "a") = = NULL) <span Style= "White-space:pre" ></span>{<span style= "White-space:pre" ></span>printf ("fopen error.\n "); <span style=" White-space:pre "></span>exit (0); <span style=" White-space:pre "&GT;&LT;/SPAN&GT;} <span style= "White-space:pre" &GT;&LT;/SPAN&GT;FPUTC (CH, FP); <span style= "White-space:pre" ></span> Fclose (FP);}

Iv. Summary of the experiment
Experiment Harvest:

Learned a lot of covert channel knowledge, but also more familiar with the Ansune operating system command usage.


Summarize the problems encountered in the experimental process and solutions:

The development of the C language program in Linux does not use the IDE, programming is very inconvenient.


Solution:

Shared with Samba in Linux, the C language code in Linux is shared with Windows so that the source code can be edited with professional Ides such as Visual Studio under Windows, ensuring that coding is done efficiently. After the encoding is complete, use the Linux SCP tool for file transfer, as shown in:




Ansune secure operating system covert channel scenario demonstration of the second "recent Access Time channel"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.