1/*
2 * Copyright (c) 2006-2013 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24//
25// macho++ - Mach-O object file helpers
26//
27#include "macho++.h"
28#include <security_utilities/alloc.h>
29#include <security_utilities/memutils.h>
30#include <security_utilities/endian.h>
31#include <mach-o/dyld.h>
32#include <list>
33#include <algorithm>
34#include <iterator>
35
36namespace Security {
37
38/* Maximum number of archs a fat binary can have */
39static const int MAX_ARCH_COUNT = 100;
40/* Maximum power of 2 that a mach-o can be aligned by */
41static const int MAX_ALIGN = 30;
42
43//
44// Architecture values
45//
46Architecture::Architecture(const fat_arch &arch)
47	: pair<cpu_type_t, cpu_subtype_t>(arch.cputype, arch.cpusubtype)
48{
49}
50
51Architecture::Architecture(const char *name)
52{
53	if (const NXArchInfo *nxa = NXGetArchInfoFromName(name)) {
54		this->first = nxa->cputype;
55		this->second = nxa->cpusubtype;
56	} else {
57		this->first = this->second = none;
58	}
59}
60
61
62//
63// The local architecture.
64//
65// We take this from ourselves - the architecture of our main program Mach-O binary.
66// There's the NXGetLocalArchInfo API, but it insists on saying "i386" on modern
67// x86_64-centric systems, and lies to ppc (Rosetta) programs claiming they're native ppc.
68// So let's not use that.
69//
70Architecture Architecture::local()
71{
72	return MainMachOImage().architecture();
73}
74
75
76//
77// Translate between names and numbers
78//
79const char *Architecture::name() const
80{
81	if (const NXArchInfo *info = NXGetArchInfoFromCpuType(cpuType(), cpuSubtype()))
82		return info->name;
83	else
84		return NULL;
85}
86
87std::string Architecture::displayName() const
88{
89	if (const char *s = this->name())
90		return s;
91	char buf[20];
92	snprintf(buf, sizeof(buf), "(%d:%d)", cpuType(), cpuSubtype());
93	return buf;
94}
95
96
97//
98// Compare architectures.
99// This is asymmetrical; the second argument provides for some templating.
100//
101bool Architecture::matches(const Architecture &templ) const
102{
103	if (first != templ.first)
104		return false;	// main architecture mismatch
105	if (templ.second == CPU_SUBTYPE_MULTIPLE)
106		return true;	// subtype wildcard
107	// match subtypes, ignoring feature bits
108	return ((second ^ templ.second) & ~CPU_SUBTYPE_MASK) == 0;
109}
110
111
112//
113// MachOBase contains knowledge of the Mach-O object file format,
114// but abstracts from any particular sourcing. It must be subclassed,
115// and the subclass must provide the file header and commands area
116// during its construction. Memory is owned by the subclass.
117//
118MachOBase::~MachOBase()
119{ /* virtual */ }
120
121// provide the Mach-O file header, somehow
122void MachOBase::initHeader(const mach_header *header)
123{
124	mHeader = header;
125	switch (mHeader->magic) {
126	case MH_MAGIC:
127		mFlip = false;
128		m64 = false;
129		break;
130	case MH_CIGAM:
131		mFlip = true;
132		m64 = false;
133		break;
134	case MH_MAGIC_64:
135		mFlip = false;
136		m64 = true;
137		break;
138	case MH_CIGAM_64:
139		mFlip = true;
140		m64 = true;
141		break;
142	default:
143		secdebug("macho", "%p: unrecognized header magic (%x)", this, mHeader->magic);
144		UnixError::throwMe(ENOEXEC);
145	}
146}
147
148// provide the Mach-O commands section, somehow
149void MachOBase::initCommands(const load_command *commands)
150{
151	mCommands = commands;
152	mEndCommands = LowLevelMemoryUtilities::increment<load_command>(commands, flip(mHeader->sizeofcmds));
153	if (mCommands + 1 > mEndCommands)	// ensure initial load command core available
154		UnixError::throwMe(ENOEXEC);
155}
156
157
158size_t MachOBase::headerSize() const
159{
160	return m64 ? sizeof(mach_header_64) : sizeof(mach_header);
161}
162
163size_t MachOBase::commandSize() const
164{
165	return flip(mHeader->sizeofcmds);
166}
167
168
169//
170// Create a MachO object from an open file and a starting offset.
171// We load (only) the header and load commands into memory at that time.
172// Note that the offset must be relative to the start of the containing file
173// (not relative to some intermediate container).
174//
175MachO::MachO(FileDesc fd, size_t offset, size_t length)
176	: FileDesc(fd), mOffset(offset), mLength(length), mSuspicious(false)
177{
178	if (mOffset == 0)
179		mLength = fd.fileSize();
180	size_t size = fd.read(&mHeaderBuffer, sizeof(mHeaderBuffer), mOffset);
181	if (size != sizeof(mHeaderBuffer))
182		UnixError::throwMe(ENOEXEC);
183	this->initHeader(&mHeaderBuffer);
184	size_t cmdSize = this->commandSize();
185	mCommandBuffer = (load_command *)malloc(cmdSize);
186	if (!mCommandBuffer)
187		UnixError::throwMe();
188	if (fd.read(mCommandBuffer, cmdSize, this->headerSize() + mOffset) != cmdSize)
189		UnixError::throwMe(ENOEXEC);
190	this->initCommands(mCommandBuffer);
191	/* If we do not know the length, we cannot do a verification of the mach-o structure */
192	if (mLength != 0)
193		this->validateStructure();
194}
195
196void MachO::validateStructure()
197{
198	bool isValid = false;
199
200	/* There should be either an LC_SEGMENT, an LC_SEGMENT_64, or an LC_SYMTAB
201	 load_command and that + size must be equal to the end of the arch */
202	for (const struct load_command *cmd = loadCommands(); cmd != NULL; cmd = nextCommand(cmd)) {
203		uint32_t cmd_type = flip(cmd->cmd);
204		struct segment_command *seg = NULL;
205		struct segment_command_64 *seg64 = NULL;
206		struct symtab_command *symtab = NULL;
207
208		if (cmd_type ==  LC_SEGMENT) {
209			seg = (struct segment_command *)cmd;
210			if (strcmp(seg->segname, SEG_LINKEDIT) == 0) {
211				isValid = flip(seg->fileoff) + flip(seg->filesize) == this->length();
212				break;
213			}
214		} else if (cmd_type == LC_SEGMENT_64) {
215			seg64 = (struct segment_command_64 *)cmd;
216			if (strcmp(seg64->segname, SEG_LINKEDIT) == 0) {
217				isValid = flip(seg64->fileoff) + flip(seg64->filesize) == this->length();
218				break;
219			}
220		/* PPC binaries have a SYMTAB section */
221		} else if (cmd_type == LC_SYMTAB) {
222			symtab = (struct symtab_command *)cmd;
223			isValid = flip(symtab->stroff) + flip(symtab->strsize) == this->length();
224			break;
225		}
226	}
227
228	if (!isValid)
229		mSuspicious = true;
230}
231
232MachO::~MachO()
233{
234	::free(mCommandBuffer);
235}
236
237
238//
239// Create a MachO object that is (entirely) mapped into memory.
240// The caller must ensire that the underlying mapping persists
241// at least as long as our object.
242//
243MachOImage::MachOImage(const void *address)
244{
245	this->initHeader((const mach_header *)address);
246	this->initCommands(LowLevelMemoryUtilities::increment<const load_command>(address, this->headerSize()));
247}
248
249
250//
251// Locate the Mach-O image of the main program
252//
253MainMachOImage::MainMachOImage()
254	: MachOImage(mainImageAddress())
255{
256}
257
258const void *MainMachOImage::mainImageAddress()
259{
260	return _dyld_get_image_header(0);
261}
262
263
264//
265// Return various header fields
266//
267Architecture MachOBase::architecture() const
268{
269	return Architecture(flip(mHeader->cputype), flip(mHeader->cpusubtype));
270}
271
272uint32_t MachOBase::type() const
273{
274	return flip(mHeader->filetype);
275}
276
277uint32_t MachOBase::flags() const
278{
279	return flip(mHeader->flags);
280}
281
282
283//
284// Iterate through load commands
285//
286const load_command *MachOBase::nextCommand(const load_command *command) const
287{
288	using LowLevelMemoryUtilities::increment;
289	command = increment<const load_command>(command, flip(command->cmdsize));
290	if (command >= mEndCommands)	// end of load commands
291		return NULL;
292	if (increment(command, sizeof(load_command)) > mEndCommands
293		|| increment(command, flip(command->cmdsize)) > mEndCommands)
294		UnixError::throwMe(ENOEXEC);
295	return command;
296}
297
298
299//
300// Find a specific load command, by command number.
301// If there are multiples, returns the first one found.
302//
303const load_command *MachOBase::findCommand(uint32_t cmd) const
304{
305	for (const load_command *command = loadCommands(); command; command = nextCommand(command))
306		if (flip(command->cmd) == cmd)
307			return command;
308	return NULL;
309}
310
311
312//
313// Locate a segment command, by name
314//
315const segment_command *MachOBase::findSegment(const char *segname) const
316{
317	for (const load_command *command = loadCommands(); command; command = nextCommand(command)) {
318		switch (flip(command->cmd)) {
319		case LC_SEGMENT:
320		case LC_SEGMENT_64:
321			{
322				const segment_command *seg = reinterpret_cast<const segment_command *>(command);
323				if (!strcmp(seg->segname, segname))
324					return seg;
325				break;
326			}
327		default:
328			break;
329		}
330	}
331	return NULL;
332}
333
334const section *MachOBase::findSection(const char *segname, const char *sectname) const
335{
336	using LowLevelMemoryUtilities::increment;
337	if (const segment_command *seg = findSegment(segname)) {
338		if (is64()) {
339			const segment_command_64 *seg64 = reinterpret_cast<const segment_command_64 *>(seg);
340			const section_64 *sect = increment<const section_64>(seg64 + 1, 0);
341			for (unsigned n = flip(seg64->nsects); n > 0; n--, sect++) {
342				if (!strcmp(sect->sectname, sectname))
343					return reinterpret_cast<const section *>(sect);
344			}
345		} else {
346			const section *sect = increment<const section>(seg + 1, 0);
347			for (unsigned n = flip(seg->nsects); n > 0; n--, sect++) {
348				if (!strcmp(sect->sectname, sectname))
349					return sect;
350			}
351		}
352	}
353	return NULL;
354}
355
356
357//
358// Translate a union lc_str into the string it denotes.
359// Returns NULL (no exceptions) if the entry is corrupt.
360//
361const char *MachOBase::string(const load_command *cmd, const lc_str &str) const
362{
363	size_t offset = flip(str.offset);
364	const char *sp = LowLevelMemoryUtilities::increment<const char>(cmd, offset);
365	if (offset + strlen(sp) + 1 > flip(cmd->cmdsize))	// corrupt string reference
366		return NULL;
367	return sp;
368}
369
370
371//
372// Figure out where the Code Signing information starts in the Mach-O binary image.
373// The code signature is at the end of the file, and identified
374// by a specially-named section. So its starting offset is also the end
375// of the signable part.
376// Note that the offset returned is relative to the start of the Mach-O image.
377// Returns zero if not found (usually indicating that the binary was not signed).
378//
379const linkedit_data_command *MachOBase::findCodeSignature() const
380{
381	if (const load_command *cmd = findCommand(LC_CODE_SIGNATURE))
382		return reinterpret_cast<const linkedit_data_command *>(cmd);
383	return NULL;		// not found
384}
385
386size_t MachOBase::signingOffset() const
387{
388	if (const linkedit_data_command *lec = findCodeSignature())
389		return flip(lec->dataoff);
390	else
391		return 0;
392}
393
394size_t MachOBase::signingLength() const
395{
396	if (const linkedit_data_command *lec = findCodeSignature())
397		return flip(lec->datasize);
398	else
399		return 0;
400}
401
402const linkedit_data_command *MachOBase::findLibraryDependencies() const
403{
404	if (const load_command *cmd = findCommand(LC_DYLIB_CODE_SIGN_DRS))
405		return reinterpret_cast<const linkedit_data_command *>(cmd);
406	return NULL;		// not found
407}
408
409
410//
411// Return the signing-limit length for this Mach-O binary image.
412// This is the signingOffset if present, or the full length if not.
413//
414size_t MachO::signingExtent() const
415{
416	if (size_t offset = signingOffset())
417		return offset;
418	else
419		return length();
420}
421
422
423//
424// I/O operations
425//
426void MachO::seek(size_t offset)
427{
428	FileDesc::seek(mOffset + offset);
429}
430
431CFDataRef MachO::dataAt(size_t offset, size_t size)
432{
433	CFMallocData buffer(size);
434	if (this->read(buffer, size, mOffset + offset) != size)
435		UnixError::throwMe();
436	return buffer;
437}
438
439//
440// Fat (aka universal) file wrappers.
441// The offset is relative to the start of the containing file.
442//
443Universal::Universal(FileDesc fd, size_t offset /* = 0 */, size_t length /* = 0 */)
444	: FileDesc(fd), mBase(offset), mLength(length), mSuspicious(false)
445{
446	union {
447		fat_header header;		// if this is a fat file
448		mach_header mheader;	// if this is a thin file
449	};
450	const size_t size = max(sizeof(header), sizeof(mheader));
451	if (fd.read(&header, size, offset) != size)
452		UnixError::throwMe(ENOEXEC);
453	switch (header.magic) {
454	case FAT_MAGIC:
455	case FAT_CIGAM:
456		{
457			//
458			// Hack alert.
459			// Under certain circumstances (15001604), mArchCount under-counts the architectures
460			// by one, and special testing is required to validate the extra-curricular entry.
461			// We always read an extra entry; in the situations where this might hit end-of-file,
462			// we are content to fail.
463			//
464			mArchCount = ntohl(header.nfat_arch);
465			size_t archSize = sizeof(fat_arch) * (mArchCount + 1);
466			mArchList = (fat_arch *)malloc(archSize);
467			if (!mArchList)
468				UnixError::throwMe();
469			if (fd.read(mArchList, archSize, mBase + sizeof(header)) != archSize) {
470				::free(mArchList);
471				UnixError::throwMe(ENOEXEC);
472			}
473			for (fat_arch *arch = mArchList; arch <= mArchList + mArchCount; arch++) {
474				n2hi(arch->cputype);
475				n2hi(arch->cpusubtype);
476				n2hi(arch->offset);
477				n2hi(arch->size);
478				n2hi(arch->align);
479			}
480			const fat_arch *last_arch = mArchList + mArchCount;
481			if (last_arch->cputype == (CPU_ARCH_ABI64 | CPU_TYPE_ARM)) {
482				mArchCount++;
483			}
484			secdebug("macho", "%p is a fat file with %d architectures",
485				this, mArchCount);
486
487			/* A Mach-O universal file has padding of no more than "page size"
488			 * between the header and slices. This padding must be zeroed out or the file
489			   is not valid */
490			std::list<struct fat_arch *> sortedList;
491			for (unsigned i = 0; i < mArchCount; i++)
492				sortedList.push_back(mArchList + i);
493
494			sortedList.sort(^ bool (const struct fat_arch *arch1, const struct fat_arch *arch2) { return arch1->offset < arch2->offset; });
495
496			const size_t universalHeaderEnd = mBase + sizeof(header) + (sizeof(fat_arch) * mArchCount);
497			size_t prevHeaderEnd = universalHeaderEnd;
498			size_t prevArchSize = 0, prevArchStart = 0;
499
500			for (auto iterator = sortedList.begin(); iterator != sortedList.end(); ++iterator) {
501				auto ret = mSizes.insert(std::pair<size_t, size_t>((*iterator)->offset, (*iterator)->size));
502				if (ret.second == false) {
503					::free(mArchList);
504					MacOSError::throwMe(errSecInternalError); // Something is wrong if the same size was encountered twice
505				}
506
507				size_t gapSize = (*iterator)->offset - prevHeaderEnd;
508
509				/* The size of the padding after the universal cannot be calculated to a fixed size */
510				if (prevHeaderEnd != universalHeaderEnd) {
511					if (((*iterator)->align > MAX_ALIGN) || gapSize >= (1 << (*iterator)->align)) {
512						mSuspicious = true;
513						break;
514					}
515				}
516
517				// validate gap bytes in tasty page-sized chunks
518				CssmAutoPtr<uint8_t> gapBytes(Allocator::standard().malloc<uint8_t>(PAGE_SIZE));
519				size_t off = 0;
520				while (off < gapSize) {
521					size_t want = min(gapSize - off, (size_t)PAGE_SIZE);
522					size_t got = fd.read(gapBytes, want, prevHeaderEnd + off);
523					off += got;
524					for (size_t x = 0; x < got; x++) {
525						if (gapBytes[x] != 0) {
526							mSuspicious = true;
527							break;
528						}
529					}
530					if (mSuspicious)
531						break;
532				}
533				if (off != gapSize)
534					mSuspicious = true;
535				if (mSuspicious)
536					break;
537
538				prevHeaderEnd = (*iterator)->offset + (*iterator)->size;
539				prevArchSize = (*iterator)->size;
540				prevArchStart = (*iterator)->offset;
541			}
542
543			/* If there is anything extra at the end of the file, reject this */
544			if (!mSuspicious && (prevArchStart + prevArchSize != fd.fileSize()))
545				mSuspicious = true;
546
547			break;
548		}
549	case MH_MAGIC:
550	case MH_MAGIC_64:
551		mArchList = NULL;
552		mArchCount = 0;
553		mThinArch = Architecture(mheader.cputype, mheader.cpusubtype);
554		secdebug("macho", "%p is a thin file (%s)", this, mThinArch.name());
555		break;
556	case MH_CIGAM:
557	case MH_CIGAM_64:
558		mArchList = NULL;
559		mArchCount = 0;
560		mThinArch = Architecture(flip(mheader.cputype), flip(mheader.cpusubtype));
561		secdebug("macho", "%p is a thin file (%s)", this, mThinArch.name());
562		break;
563	default:
564		UnixError::throwMe(ENOEXEC);
565	}
566}
567
568Universal::~Universal()
569{
570	::free(mArchList);
571}
572
573const size_t Universal::lengthOfSlice(size_t offset) const
574{
575	auto ret = mSizes.find(offset);
576	if (ret == mSizes.end())
577		MacOSError::throwMe(errSecInternalError);
578	return ret->second;
579}
580
581//
582// Get the "local" architecture from the fat file
583// Throws ENOEXEC if not found.
584//
585MachO *Universal::architecture() const
586{
587	if (isUniversal())
588		return findImage(bestNativeArch());
589	else
590		return new MachO(*this, mBase, mLength);
591}
592
593size_t Universal::archOffset() const
594{
595	if (isUniversal())
596		return mBase + findArch(bestNativeArch())->offset;
597	else
598		return mBase;
599}
600
601
602//
603// Get the specified architecture from the fat file
604// Throws ENOEXEC if not found.
605//
606MachO *Universal::architecture(const Architecture &arch) const
607{
608	if (isUniversal())
609		return findImage(arch);
610	else if (mThinArch.matches(arch))
611		return new MachO(*this, mBase);
612	else
613		UnixError::throwMe(ENOEXEC);
614}
615
616size_t Universal::archOffset(const Architecture &arch) const
617{
618	if (isUniversal())
619		return mBase + findArch(arch)->offset;
620	else if (mThinArch.matches(arch))
621		return 0;
622	else
623		UnixError::throwMe(ENOEXEC);
624}
625
626size_t Universal::archLength(const Architecture &arch) const
627{
628	if (isUniversal())
629		return mBase + findArch(arch)->size;
630	else if (mThinArch.matches(arch))
631		return this->fileSize();
632	else
633		UnixError::throwMe(ENOEXEC);
634}
635
636//
637// Get the architecture at a specified offset from the fat file.
638// Throws an exception of the offset does not point at a Mach-O image.
639//
640MachO *Universal::architecture(size_t offset) const
641{
642	if (isUniversal())
643		return new MachO(*this, offset);
644	else if (offset == mBase)
645		return new MachO(*this);
646	else
647		UnixError::throwMe(ENOEXEC);
648}
649
650
651//
652// Locate an architecture from the fat file's list.
653// Throws ENOEXEC if not found.
654//
655const fat_arch *Universal::findArch(const Architecture &target) const
656{
657	assert(isUniversal());
658	const fat_arch *end = mArchList + mArchCount;
659	// exact match
660	for (const fat_arch *arch = mArchList; arch < end; ++arch)
661		if (arch->cputype == target.cpuType()
662			&& arch->cpusubtype == target.cpuSubtype())
663			return arch;
664	// match for generic model of main architecture
665	for (const fat_arch *arch = mArchList; arch < end; ++arch)
666		if (arch->cputype == target.cpuType() && arch->cpusubtype == 0)
667			return arch;
668	// match for any subarchitecture of the main architecture (questionable)
669	for (const fat_arch *arch = mArchList; arch < end; ++arch)
670		if (arch->cputype == target.cpuType())
671			return arch;
672	// no match
673	UnixError::throwMe(ENOEXEC);	// not found
674}
675
676MachO *Universal::findImage(const Architecture &target) const
677{
678	const fat_arch *arch = findArch(target);
679	return new MachO(*this, mBase + arch->offset, arch->size);
680}
681
682
683//
684// Find the best-matching architecture for this fat file.
685// We pick the native architecture if it's available.
686// If it contains exactly one architecture, we take that.
687// Otherwise, we throw.
688//
689Architecture Universal::bestNativeArch() const
690{
691	if (isUniversal()) {
692		// ask the NXArch API for our native architecture
693		const Architecture native = Architecture::local();
694		if (fat_arch *match = NXFindBestFatArch(native.cpuType(), native.cpuSubtype(), mArchList, mArchCount))
695			return *match;
696		// if the system can't figure it out, pick (arbitrarily) the first one
697		return mArchList[0];
698	} else
699		return mThinArch;
700}
701
702//
703// List all architectures from the fat file's list.
704//
705void Universal::architectures(Architectures &archs) const
706{
707	if (isUniversal()) {
708		for (unsigned n = 0; n < mArchCount; n++)
709			archs.insert(mArchList[n]);
710	} else {
711		auto_ptr<MachO> macho(architecture());
712		archs.insert(macho->architecture());
713	}
714}
715
716//
717// Quickly guess the Mach-O type of a file.
718// Returns type zero if the file isn't Mach-O or Universal.
719// Always looks at the start of the file, and does not change the file pointer.
720//
721uint32_t Universal::typeOf(FileDesc fd)
722{
723	mach_header header;
724	int max_tries = 3;
725	if (fd.read(&header, sizeof(header), 0) != sizeof(header))
726		return 0;
727	while (max_tries > 0) {
728		switch (header.magic) {
729		case MH_MAGIC:
730		case MH_MAGIC_64:
731			return header.filetype;
732			break;
733		case MH_CIGAM:
734		case MH_CIGAM_64:
735			return flip(header.filetype);
736			break;
737		case FAT_MAGIC:
738		case FAT_CIGAM:
739			{
740				const fat_arch *arch1 =
741					LowLevelMemoryUtilities::increment<fat_arch>(&header, sizeof(fat_header));
742				if (fd.read(&header, sizeof(header), ntohl(arch1->offset)) != sizeof(header))
743					return 0;
744				max_tries--;
745				continue;
746			}
747		default:
748			return 0;
749		}
750	}
751    return 0;
752}
753
754//
755// Strict validation
756//
757bool Universal::isSuspicious() const
758{
759	if (mSuspicious)
760		return true;
761	Universal::Architectures archList;
762	architectures(archList);
763	for (Universal::Architectures::const_iterator it = archList.begin(); it != archList.end(); ++it) {
764		auto_ptr<MachO> macho(architecture(*it));
765		if (macho->isSuspicious())
766			return true;
767	}
768	return false;
769}
770
771
772} // Security
773